Keep in mind beginner mode on here.
I am making an e-commerce site that searches products from a database.
The login I use is based on 0s and 1s in database.
When logged in as admin and using search feature on admin.php page i get logged out or redirected to frontPage. The same search feature works properly on the frontPage.

This is the part where i submit form on admin.php.

```
<div id="mainArea">
    <form id="searchBox" action="<?=$_SERVER['PHP_SELF']?>" method="post"><input id="search" name="title" type="text" placeholder="Search Products" /><input name="submit" type="submit" value="Search" style="width:75px;height:36px"/></form>
</div>
    <div id="show">
        <?php
            include("searchAdmin.php");
        ?> 
    </div>

```

Top of the admin.php page looks like this :

```
<?php
session_start();
$name = $_SESSION['myusername'];
?>

```

Search is this in adminSearch.php:

```
<?php
if ($_POST['submit']){
include ("connection.php");

$title = (trim($_POST['title'])=="")?
die ("You did not enter any search criteria"):
mysql_real_escape_string($_POST['title']);

$query = "select * from beer where upper(beer_name) like '%".strtoupper($title) ."%' OR upper(beer_descr) like '%". strtoupper($title) ."%' OR upper(beer_categ) like '%". strtoupper($title) ."%'";

if(! ($result = mysql_query($query)))
die ("No matches found. Please search again.</body></html>");
echo "<table border=1>";
while ($rows = mysql_fetch_array($result)) {
    echo "<tr><td rowspan=3>" . '<img src="images/'. $rows['beer_image'] . '.jpg"/>'."</td><td>".$rows['beer_name']."</td><td><a href='updateBeer.php?id=". $rows['beer_id'] ."'>Update</a></td></tr>";
    echo "<tr><td>".$rows['beer_categ']."</td><td><a href='deleteBeer.php?id=". $rows['beer_id'] ."'>Delete</a></td></tr>";
    echo "<tr><td>".$rows['beer_descr']."</td>
    <td>".$rows['beer_cost']."</td></tr>";
}
echo "</table>";
}
else include("showAdmin.php");
?>

```

Edit: Forgot to show the end of my login php looks like this.
It sends me to admin page properly but when i do the search on the admin page it logs me out or sends me to frontPage.

```
    if($count==1){
        if($auth==1){
            session_start();
            $_SESSION['myusername'] = $myusername;
            $_SESSION['auth']=$auth;
            header("location: /admin.php");
            }
        elseif($auth==0){
            session_start();
            $_SESSION['myusername'] = $myusername;
            $_SESSION['auth']=$auth;
            header("location: /user.php");
        }
    }
else {
echo "Wrong Username or Password";
}

```

My logout looks like this on same admin page:

```
<div id="login1">
<font color="white">Logged in with Administrator privilages as: <?php echo $name ?>.</font><br /><form id="logout" method="post" name="logout" action="logout.php"><input name="logout" type="submit" value="Logout" style="width:75px;height:22px"><br />
</div>     

```

And the logout.php reads:

```
<?php
if (!empty($_POST['logout'])){
session_start();
session_destroy();
header("location: /frontPage.php");
}
?>

```