On Sun, 24 Oct 2004 09:22:26 +0200, A strange species called
"Janwillem Borleffs" <jw@jwscripts.com> wrote:
What header problems do you have? Starting with a call to session_start(),
followed by a header() call shouldn't cause any problems.
Even several header() calls do not cause errors, because headers are send
only when content is displayed or at the end of the script (whatever comes
first):
<?php
// header not send
header("X-Header: Foo");
header("X-Header-Description: Bar");
// headers are send
print "Hello";
// Error because the headers are already sent
header("Location: http://example.com/");
?>
Or:
<?php
// header not send
header("X-Header: Foo");
header("X-Header-Description: Bar");
header("Location: http://example.com/");
// No more lines of code, headers will be send
?>
Even the above examples would work when you instruct PHP to wait sending the
output through output buffering (see http://www.php.net/ob_start).
JW
Hi.
I receive the following error:
Warning: Cannot modify header information - headers already sent by
(output started at /home/xxxxx/public_html/newland/login.php:11) in
/home/xxxxx/public_html/newland/login.php on line 55
This is line 55 to 61 below:
header("Location: ". $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
Do I just move that to the top then after the session start?
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('Connections/conn_newland.php'); ?>
<?php
// *** Validate request to login to this site.
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($accesscheck)) {
$GLOBALS['PrevUrl'] = $accesscheck;
session_register('PrevUrl');
}
if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['pwd'];
$MM_fldUserAuthorization = "userGroup";
$MM_redirectLoginSuccess = "index.php";
$MM_redirectLoginFailed = "login_failed.php";
$MM_redirecttoReferrer = true;
mysql_select_db($database_conn_newland, $conn_newland);
$LoginRS__query=sprintf("SELECT username, pwd, userGroup FROM
tbl_users WHERE username='%s' AND pwd='%s'",
get_magic_quotes_gpc() ? $loginUsername :
addslashes($loginUsername), get_magic_quotes_gpc() ? $password :
addslashes($password));
$LoginRS = mysql_query($LoginRS__query, $conn_newland) 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']) && true) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: ". $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>