Hi
Im having trouble try to figuring out on how to redirect two different types of users to two different pages in a single login form.
Basically what I want is if a regular user logs in, he will be directed to user_mainpage.php but if the website administrator logs in, he will be directed to admin_mainpage.php. Both of them will use the same login form. Is this possible? If so, can you please teach me how to code this.
To differentiate an admin from the user, I have a column in the database table named Type. If the type = admin, then person logging in is an administrator. If the type = user, then the person is logging in as a user.
Here's my current code - it doesnt work and this is the only solution I can think of
$sql="SELECT * FROM $tbl_name WHERE UserName='$username' AND Password='$password'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1)
{
if (type=='u')
{
$_SESSION['username'] = $username;
header("location:user_myaccount.php");
}
else
{
$_SESSION['username'] = $username;
header("location:admin_main.php");
}
}
Thanks in advance.