Hi Guys!
I have created a login page in php and session variables that would hopefully record username, password and the Usergroup.
The idea is that a user logs in (attached to their record in the database is a "Usergroup" field specifying either "admin" or "visitor" values) and is restricted access to certain pages/or granted access based on the value of their "Usergroup".
The problem I have is that the session variables that are created from the log in are insufficient. They look like this:
MM_Username|N;MM_UserGroup|N;
There are no values attached to them and the Usergroup and it's value are not present.
This means that the whole login is useless, and I cannot restrict/grant access to users.
I don't know how to rectify this.
could someone help?
I have created a login page in php and session variables that would hopefully record username, password and the Usergroup.
The idea is that a user logs in (attached to their record in the database is a "Usergroup" field specifying either "admin" or "visitor" values) and is restricted access to certain pages/or granted access based on the value of their "Usergroup".
The problem I have is that the session variables that are created from the log in are insufficient. They look like this:
MM_Username|N;MM_UserGroup|N;
There are no values attached to them and the Usergroup and it's value are not present.
This means that the whole login is useless, and I cannot restrict/grant access to users.
I don't know how to rectify this.
could someone help?
Code:
<?php
session_start();
?>
<?php require_once('../Connections/XXXXX.php'); ?>
<?php
// *** Validate request to login to this site.
session_start();
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($accesscheck)) {
$GLOBALS['PrevUrl'] = $accesscheck;
session_register('PrevUrl');
}
if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "Usergroup";
$MM_redirectLoginSuccess = "successful.php";
$MM_redirectLoginFailed = "failed.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_XXXX, $XXXX);
$LoginRS__query=sprintf("SELECT Email, Password, Usergroup FROM users WHERE Email='%s' AND Password='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));
$LoginRS = mysql_query($LoginRS__query, $gymtvdb) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = mysql_result($LoginRS,0,'Usergroup');
//declare two session variables and assign them
$GLOBALS['MM_Username'] = $loginUsername;
$GLOBALS['MM_UserGroup'] = $loginStrGroup;
//register the session variables
session_register("MM_Username");
session_register("MM_UserGroup");
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>