Problems in maintaining sessions for admin and user
<p>I Wanted to ask that i have a main login page where user and admin both have different pages further 
if the username and password entered is any user "from my sql table " then it will direct to the user page , and if the username and password on my main login is </p>

<p>: administrator (username)
: admin ( password)</p>

<p>Then it should redirect to my Admin page </p>

<p>Now the problem is when i login as either , it is directing me to that user page</p>

<p>Plz helppp !!</p>

<pre><code>&lt;?php
$host="localhost"; // Host name
$username="SM"; // Mysql username
$password="123"; // Mysql password
$db_name="rfid"; // Database name
$tbl_name="user"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// username and password sent from form
//$myusername=$_POST['name'];
$myusername = array_key_exists('myusername', $_POST) ? $_POST['myusername'] : null;

//$mypassword=$_POST['password'];
$mypassword = array_key_exists('mypassword', $_POST) ? $_POST['mypassword'] : null;


// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);

//$sql="SELECT * FROM $tbl_name WHERE myusername='$myusername' and mypassword='$mypassword'";
$sql="SELECT * FROM rfid.user WHERE myusername='$myusername' and mypassword='$mypassword'";
$result=mysql_query($sql);
//$row=mysql_fetch_array($result);
//$active=$row['active'];

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);

// If result matched $myusername and $mypassword, table row must be 1 row

if($count==1){

// Register $myusername, $mypassword and redirect to file "login_success.php"
session_start();
//session_register($myusername);
$_SESSION['myusername']='myusername';
//session_register($mypassword);
$_SESSION['mypassword']='mypassword';
header("location:login_success.php");


}
else {
echo "Wrong Username or Password";
}
?&gt;
</code></pre>
