user access levels
Posted: Fri Nov 22, 2002 9:46 pm
Hi,
I'm trying to setup a login script that checks a username and password, then selects an admin level from may database for that user, then process the admin level into a switch statement.
i have checked that the username and password are correct.
mysql query executes.
but i'm having trouble assigning the admin level abstracted from the database to a variable for the switch statment.
sample code
// query and return result
$query = "SELECT level FROM admin WHERE loginname='$loginname' AND loginpassword='$loginpassword'";
$result = mysql_db_query ($databasename, $query, $connection);
//heres where i have the problem, how to i pass the value of 'level'
// abstracted from the database to the variable $access for the
//switch statment to process.
switch ($access) {
case "all":
print ("Access all areas");
break;
case "level1":
print ("You can only access level 1");
break;
default:
print ("Error at login contact admin");
}
Any help would be greatly appreciated.
Thanks Sinus
I'm trying to setup a login script that checks a username and password, then selects an admin level from may database for that user, then process the admin level into a switch statement.
i have checked that the username and password are correct.
mysql query executes.
but i'm having trouble assigning the admin level abstracted from the database to a variable for the switch statment.
sample code
// query and return result
$query = "SELECT level FROM admin WHERE loginname='$loginname' AND loginpassword='$loginpassword'";
$result = mysql_db_query ($databasename, $query, $connection);
//heres where i have the problem, how to i pass the value of 'level'
// abstracted from the database to the variable $access for the
//switch statment to process.
switch ($access) {
case "all":
print ("Access all areas");
break;
case "level1":
print ("You can only access level 1");
break;
default:
print ("Error at login contact admin");
}
Any help would be greatly appreciated.
Thanks Sinus