Hi.
I am having a few header problems at the moment with a login page. I
don't have my headers at the top of the page where I've learned I need
to have them. However, I also know I'm supposed to have the
session_start() ; at the top of the page as well. So when you have two
things that need to be the first which do you put first? And if I put
one before the other will that cause problems?
Below is a copy of the php from my page. It is the header("Locatio n:
". parts at the bottom in the registering session variables section
that causes the error. Would I just lift out the header locations
parts and put them to the top?
Thanks for any help
John
<?php
session_start() ;
// *** Validate request to login to this site.
//session_start() ;
// Report all PHP errors (bitwise 63 may be used in PHP 3)
error_reporting (E_ALL);
?>
<?php require_once('C onnections/conn_newland.ph p'); ?>
<?php
// *** Validate request to login to this site.
$loginFormActio n = $_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 );
}
}
?>