Jump to content

Page redirect help


fife

Recommended Posts

Hi.  I am trying to make a signing in script send users with access level 1 to one members area, level 2 to another and level 3 to another!  Now i have made the script so it checks their access level but i dont understand how to make it send the users to different areas!  Level onces can sign in fine.  Can someone please show me the error of my ways in my code and how to fix it?

 

<?
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['Username1'])) {
  $loginUsername=$_POST['Username'];
  $password=$_POST['Password'];
  $MM_fldUserAuthorization = "Accesslevel";
  $MM_redirectLoginSuccess = "level1.php";
  $MM_redirectLoginFailed = "Signinfail.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_con1, $con1);
  	
  $LoginRS__query=sprintf("SELECT Username, Password, Accesslevel FROM Members WHERE Username=%s AND Password=%s",
  GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
   
  $LoginRS = mysql_query($LoginRS__query, $connection1) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
    
    $loginStrGroup  = mysql_result($LoginRS,0,'Accesslevel');
    
   
    $_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/115133-page-redirect-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.