Hello, I am learning more PHP & MySQL everyday, but...
Does anyone know how i can edit my "log in user" script so that i can have different level users directed to different start-pages. I based this a ColFusion script, and while this works perfectly, i cannot get user=admin to see admin.php, and user=client to go to client.php.
Any tips would be much appreciated.
Here's the code----------------------------------------
<?php
session_start();
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($accesscheck)) {
$GLOBALS['PrevUrl'] = $accesscheck;
session_register('PrevUrl');
}
if (isset($POST['username'])) {
$loginUsername=$POST['username'];
$password=$_POST['userword'];
$fldUserAuthorization = "userlevel";
$redirectLoginSuccess = "client.php";
$redirectLoginFailed = "loginfail.php";
$redirecttoReferrer = false;
mysql_select_db($database_ConDB, $ConD😎;
$LoginRS__query=sprintf("SELECT username, username, userlevel FROM tbsecurity WHERE username='%s' AND username='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));
$LoginRS = mysql_query($LoginRS__query, $ConD😎 or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = mysql_result($LoginRS,0,'userlevel');
//declare two session variables and assign them
$GLOBALS['Username'] = $loginUsername;
$GLOBALS['UserGroup'] = $loginStrGroup;
//register the session variables
session_register("Username");
session_register("UserGroup");
if (isset($SESSION['PrevUrl']) && false) {
$redirectLoginSuccess = $SESSION['PrevUrl'];
}
header("Location: " . $redirectLoginSuccess );
}
else {
header("Location: ". $redirectLoginFailed );
}
}