marlowkoch Posted July 9, 2008 Share Posted July 9, 2008 I am trying to add another redirect based on user security levls in mysql database. So for example I would like level 3 to redirect to mysite.com/site1 and level 1 to mysite.com/site2. Currently I am stuck and can't get it to work. Here is the current script I am using to loggin. Please help me add security level redirects.. Thanks <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['Username'])) { $loginUsername=$_POST['Username']; $password=$_POST['Password']; $MM_fldUserAuthorization = "level"; $MM_redirectLoginSuccess = "main.php"; $MM_redirectLoginFailed = "tryagain.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_setup, $setup); $LoginRS__query=sprintf("SELECT username, password, level FROM users WHERE username=%s AND password=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $setup) 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']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> Link to comment https://forums.phpfreaks.com/topic/113842-different-level-redirects/ Share on other sites More sharing options...
trq Posted July 9, 2008 Share Posted July 9, 2008 The concept is simple, I'm not digging through dreamweaver generated code, but I'll give you a simple example. <?php // validate and login user, storing there userlevel in $_SESSION['u_level']. // redirect based on userlevel. switch ($_SESSION['u_level']) { case 3: $redirect = 'mysite.com/site1'; break; case 1: $redirect = 'mysite.com/site2'; break; default: $redirect = 'mysite.com'; } header("Location: http://" . $redirect); ?> Link to comment https://forums.phpfreaks.com/topic/113842-different-level-redirects/#findComment-585132 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.