0

hi
i have a table which has
uname,pss,type fields
now i want to check the login (ie is username and password) and if the type is administrator then redirect to a different page...
if the type is a user then redirect him to another page...
in this apllication there are more than one administrator.please do tell me how to write

mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$myusername=$_POST;
$mypassword=$_POST;
$_SESSION[uname] = "$myusername";
$sql="SELECT * FROM login WHERE uname='$myusername' and pss='$mypassword'";
$result=mysql_query($sql);

// 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_register("myusername");
session_register("mypassword");
print "<script language=\"JavaScript\">";
print "window.location = 'hi.php'";
print "</script>";

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by ryan_vietnow
0

you can add something like:

$type=mysql_result($result,0,"type");
if ($type=="administrator")
{
header("location:admin.php");}
else
{
header("location:user.php");
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.