Hi
I just wondered if anyone can spot anything wrong with the following?
I have now added the session_start() ; as the first command in the code
to all the pages needing it.
When I click on a webpage that is restricted, it takes me to the login
page fine. When I login though instead of taking me to the page I
clicked previous to that, it always takes me to the index file, and
when I try to then click on the page I wanted to go to, it takes me
back to the login page. I think something must be wrong with my
coding, unless of course there is still a session related problem?
Thanks for any help on this one.
John
<?php
// *** Validate request to login to this site.
session_start() ;
?>
<?php require_once('C onnections/conn_newland.ph p'); ?>
<?php
$logarIthmIcal = $_SERVER['PHP_SELF'];
if (isset($accessc heck)) {
$GLOBALS['PrevUrl'] = $accesscheck;
session_registe r('PrevUrl');
}
if (isset($_POST['username'])) {
$loginUsername= $_POST['username'];
$password=$_POS T['pwd'];
$MM_fldUserAuth orization = "userGroup" ;
$MM_redirectLog inSuccess = "index.php" ;
$MM_redirectLog inFailed = "login_failed.p hp";
$MM_redirecttoR eferrer = true;
mysql_select_db ($database_conn _newland, $conn_newland);
$LoginRS__query =sprintf("SELEC T username, pwd, userGroup FROM
tbl_users WHERE username='%s' AND pwd='%s'",
get_magic_quote s_gpc() ? $loginUsername :
addslashes($log inUsername), get_magic_quote s_gpc() ? $password :
addslashes($pas sword));
$LoginRS = mysql_query($Lo ginRS__query, $conn_newland) or
die(mysql_error ());
$loginFoundUser = mysql_num_rows( $LoginRS);
if ($loginFoundUse r) {
$loginStrGroup = mysql_result($L oginRS,0,'userG roup');
//declare two session variables and assign them
$GLOBALS['MM_Username'] = $loginUsername;
$GLOBALS['MM_UserGroup'] = $loginStrGroup;
//register the session variables
session_registe r("MM_Username" );
session_registe r("MM_UserGroup ");
if (isset($_SESSIO N['PrevUrl']) && true) {
$MM_redirectLog inSuccess = $_SESSION['PrevUrl'];
}
header("Locatio n: " . $MM_redirectLog inSuccess );
}
else {
header("Locatio n: ". $MM_redirectLog inFailed );
}
}
?>
I just wondered if anyone can spot anything wrong with the following?
I have now added the session_start() ; as the first command in the code
to all the pages needing it.
When I click on a webpage that is restricted, it takes me to the login
page fine. When I login though instead of taking me to the page I
clicked previous to that, it always takes me to the index file, and
when I try to then click on the page I wanted to go to, it takes me
back to the login page. I think something must be wrong with my
coding, unless of course there is still a session related problem?
Thanks for any help on this one.
John
<?php
// *** Validate request to login to this site.
session_start() ;
?>
<?php require_once('C onnections/conn_newland.ph p'); ?>
<?php
$logarIthmIcal = $_SERVER['PHP_SELF'];
if (isset($accessc heck)) {
$GLOBALS['PrevUrl'] = $accesscheck;
session_registe r('PrevUrl');
}
if (isset($_POST['username'])) {
$loginUsername= $_POST['username'];
$password=$_POS T['pwd'];
$MM_fldUserAuth orization = "userGroup" ;
$MM_redirectLog inSuccess = "index.php" ;
$MM_redirectLog inFailed = "login_failed.p hp";
$MM_redirecttoR eferrer = true;
mysql_select_db ($database_conn _newland, $conn_newland);
$LoginRS__query =sprintf("SELEC T username, pwd, userGroup FROM
tbl_users WHERE username='%s' AND pwd='%s'",
get_magic_quote s_gpc() ? $loginUsername :
addslashes($log inUsername), get_magic_quote s_gpc() ? $password :
addslashes($pas sword));
$LoginRS = mysql_query($Lo ginRS__query, $conn_newland) or
die(mysql_error ());
$loginFoundUser = mysql_num_rows( $LoginRS);
if ($loginFoundUse r) {
$loginStrGroup = mysql_result($L oginRS,0,'userG roup');
//declare two session variables and assign them
$GLOBALS['MM_Username'] = $loginUsername;
$GLOBALS['MM_UserGroup'] = $loginStrGroup;
//register the session variables
session_registe r("MM_Username" );
session_registe r("MM_UserGroup ");
if (isset($_SESSIO N['PrevUrl']) && true) {
$MM_redirectLog inSuccess = $_SESSION['PrevUrl'];
}
header("Locatio n: " . $MM_redirectLog inSuccess );
}
else {
header("Locatio n: ". $MM_redirectLog inFailed );
}
}
?>
Comment