I have developed a simple search page but I can't seem to get it to work. I'm faced with 2 problems, which I think are linked. When I go on the search form page, the error:
Notice: Undefined index: userlogged in header.php on line 36 Notice: Undefined index: adminlogged in header.php on line 59`
And when using the search form using valid test data, these errors are shown:
Notice: A session had already been started - ignoring session_start() in header.php on line 3 Notice: Undefined index: userlogged in header.php on line 36 Notice: Undefined index: adminlogged in header.php on line 59 mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement in search.php on line 12
I wont post the header.php as I think it's because of the bind_result, however I'm not sure how I've done this wrong. 
I have tried removing the session_start() from header.php so it's not included automatically, but that just throws this error:
Notice: Undefined variable: _SESSION in header.php on line 36 Notice: Undefined variable: _SESSION in header.php on line 59
Searchform.php
<?php
    ob_start();
    error_reporting(E_ALL);
?>
<br><br><br>
<?php
    ini_set('display_errors', -1);
    include 'header.php';
    include 'connection.php';
?>
<br /><br />
<html>
    <header>
        <link rel="stylesheet" type="text/css" href="web.css" />    
        <link rel="stylesheet" type="text/css" href="/web.css" />
    </header>
    <body>
        <center>
            <h2>Search for people</h2>
            <br />
            Please enter the name you wish to search for<br /><br />
            <form method="post" action="search.php" id="searchform">
                <input  type="text" name="name"> 
                <input  type="submit" name="searchsubmit" value="Submit"> 
            </form>
            <br /><br/>
            Or search people by category
        </center>                  
    </body>
</html>
Search.php
<?php
    if(isset($_POST['searchsubmit']))
    {
        include 'searchform.php';
        include 'header.php';
        $name = $_POST['name'];
        if ($stmt = $connection->prepare ("SELECT * FROM users WHERE Username = ?")) 
        {
            $stmt->bind_param('s', $name);
            $stmt->execute();
            $stmt->bind_result($personresult);
            $stmt->fetch();
            print_r($personresult);
        } 
        else
        { 
            echo "<p>Please enter a search query</p>"; 
        } 
    }
    else 
    {
         echo "NOT SET!";
    }
?>
 
     
    