Hello all,
For the site i am setting up i want to have one login form to log in both normal users and administrators.
For the login form i want users to be redirected to the user homepage and likewise for the admins. The field level_user in the database holds the access level which is 1 for a user and 0 for an admin.
Part of my login code to try and do this is below, is just can't figure it out, any help would be greatly appreciated. thanks
$LoginRS__query=sprintf("SELECT username_user, password_user, level_user AS 'level' FROM tbl_user WHERE username_user=%s AND password_user=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $frox_db) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = mysql_result($LoginRS,0,'level');
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
if('level'==0)
{
header("Location: " . $MM_redirectLoginSuccessAdmin );
}
else
{
header("Location: " . $MM_redirectLoginSuccessUser );
}