Jump to content

still cant get url location to work


scottreid1974

Recommended Posts

Hi,

I want to direct a user to there unique url when they login. The url is stored in mysql table called users, along with id, password and username.

I cant get the redirection to happen, all i get is put back to my login page,  my code is below

plz help

<?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 = "access";
  $MM_redirectLoginFailed = "login.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_testconn1, $testconn1);
 
  $LoginRS__query=sprintf("SELECT username, password, url, access FROM users WHERE username=%s AND password=%s",
  GetSQLValueString($loginUsername, "text"),GetSQLValueString($url, "text"), GetSQLValueString($password, "text"));
 
  $LoginRS = mysql_query($LoginRS__query, $testconn1) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
 
 

$loginStrGroup = mysql_result ($LoginRS,0,'access');


$result = mysql_query("select url from users");
while( $usersURL = mysql_fetch_array ( $query ) )
$url=$usersURL["url"];


    //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: '.$usersURL);
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>
Link to comment
https://forums.phpfreaks.com/topic/35839-still-cant-get-url-location-to-work/
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.