php multi-level login system not working!
Posted: Tue Aug 19, 2008 10:56 pm
Okay i am trying to make a multi-level login system. I have 3 fields in the users table, login, password, and subtype.
Depending on subtype i want to login to one of 3 different panels.
I cannot get this to work for the life of me!!! Please help!
Depending on subtype i want to login to one of 3 different panels.
I cannot get this to work for the life of me!!! Please help!
Code: Select all
<?php
$db_host = 'localhost';
$db_user = '****';
$db_pass = '*****';
$db_db = '******';
$con = mysql_connect($db_host, $db_user, $db_pass) or die('MySQl Connection Error:'.mysql_error());
mysql_select_db($db_db, $con) or die('MySQL Error: Cannot select table');
$user = $_POST['login'];
$passwd = $_POST['password'];
$sql0 = "SELECT * FROM users";
$results = mysql_query($sql0,$con);
while($row = mysql_fetch_array($results))
if ($user == $row['login'] && $passwd == $row['password'])
{
$subtype = $row['subtype'];
//typecheck
if ($subtype="atype") {
print "<META HTTP-EQUIV=\"refresh\" content=\"2; URL=/*****/a.php\">";
}
elseif ($subtype="btype") {
print "<META HTTP-EQUIV=\"refresh\" content=\"2; URL=/******r/b.php\">";
}
elseif ($subtype="ctype") {
print "<META HTTP-EQUIV=\"refresh\" content=\"2; URL=/******/c.php\">";
}
//end of typecheck
}
else {
print "<META HTTP-EQUIV=\"refresh\" content=\"2; URL=/index.html\">";
}
mysql_close ($con);
?>