Jump to content

login redirect


rawky1976

Recommended Posts

Hi all, DW has created the following but it always re-directs to the loginFailure page! Any ideas why?

 

<?php require_once('Connections/connKB.php'); ?>

<?php

mysql_select_db($database_connKB, $connKB);

$query_rsUsers = "SELECT username, password FROM users";

$rsUsers = mysql_query($query_rsUsers, $connKB) or die(mysql_error());

$row_rsUsers = mysql_fetch_assoc($rsUsers);

$totalRows_rsUsers = mysql_num_rows($rsUsers);

?>

<?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 = "";

  $MM_redirectLoginSuccess = "loggedInIndex.php";

  $MM_redirectLoginFailed = "loginFailure.php";

  $MM_redirecttoReferrer = false;

  mysql_select_db($database_connKB, $connKB);

 

  $LoginRS__query=sprintf("SELECT username, password FROM users WHERE username='%s' AND password='%s'",

    get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));

 

  $LoginRS = mysql_query($LoginRS__query, $connKB) or die(mysql_error());

  $loginFoundUser = mysql_num_rows($LoginRS);

  if ($loginFoundUser) {

    $loginStrGroup = "";

   

    //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 );

  }

}

?>

 

Thanks to anyone that can help!!!

 

Mark

Link to comment
https://forums.phpfreaks.com/topic/39538-login-redirect/
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.