Westmatrix99 wrote:
> I want to get any data that I need from the database in
order to assign it to a session variable?
> This must happen at the login page.
I've just noticed that the PHP login code you have posted
appears to be
the buggy version from MX 2004.
To start off with, you need to do a Find and Replace
operation. Find
$GLOBALS and replace with $_SESSION. Also comment out all
lines that
begin with session_register.
<?php require_once('../Connections/cnmail.php'); ?>
<?php
// *** Validate request to login to this site.
session_start();
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($accesscheck)) {
//*************** Make changes here*************
$GLOBALS['PrevUrl'] = $accesscheck; <----- should be
$_SESSION['PrevUrl']
// session_register('PrevUrl'); <----- needs to be
commented out
}
// *********************************************
if (isset($_POST['userid'])) {
$loginUsername=$_POST['userid'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "index.php";
$MM_redirectLoginFailed = "dreamweaver.php";
$MM_redirecttoReferrer = true;
mysql_select_db($database_cnmail, $cnmail);
//******************************************************************
// Change the SQL here. Delete username, password and replace
with *
$LoginRS__query=sprintf("SELECT * 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, $cnmail) or
die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
//*********** Get the results from the database query
$row = mysql_fetch_assoc($LoginRS);
//****************************************************
if ($loginFoundUser) {
$loginStrGroup = "";
// ********************************
//declare two session variables and assign them
$GLOBALS['MM_Username'] = $loginUsername; <----- Should
be
$_SESSION['MM_Username']
$GLOBALS['MM_UserGroup'] = $loginStrGroup; <---- Should
be
$_SESSION ['MM_UserGroup']
// Create any session variable here
$_SESSION['fieldName'] = $row['fieldName'];
//register the session variables
//session_register("MM_Username");
//session_register("MM_UserGroup");
// ************************************************
if (isset($_SESSION['PrevUrl']) && true) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/