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>";

you can add something like:

$type=mysql_result($result,0,"type");
if ($type=="administrator")
{
header("location:admin.php");}
else
{
header("location:user.php");
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.