Forums

PHP

This topic is locked

Userlogin and dynamic redirect with PHP

Posted 28 Oct 2006 03:05:21
1
has voted
28 Oct 2006 03:05:21 Mr. J posted:
First off let me say that I'm completely NEW to this...sorry in advance and I have searched the forums and internet EXTENSIVELY on this subject and have found useful information but I am still falling short of success. I'm using DW8, PHP

As stated I want to be able to redirect someone after they login to another PHP page that I indicate. I've created a table with 3 rows, username, password, and ID. Now I figured the ID row would contain the information I would use to help redirect but still no success for me and maybe I don't even need the ID row.

I followed the help Chris provided for a simialr issue www.dmxzone.com/forum/topic.asp?topic_id=31019
but I'm missing something I think.

Here's what I got so far:

<?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 = "menu.php";
$MM_redirectLoginFailed = "sign_in.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_Accounts, $Accounts);

$LoginRS__query=sprintf("SELECT username, password FROM login 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, $Accounts) 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 );
}
}
?>

Thank You TONS if you can provide some help and even better a resolution!!! Not sure if it's crazier if I got to keep staring at these lines of code....or that I'm actually starting to understand it.

DW 8 / PHP

Reply to this topic