Ask a Question related to PHP Development, Design and Development.
-
John #1
Headers already sent?
Hello.
I just wondered if anyone has experienced this error before?
"Warning: Cannot modify header information - headers already sent."
Thanks for any help
John
John Guest
-
Please help me to set my headers and footers
I have to use these settings for my books. Margin In Inches Book Size In Inches 5-1/2 x 8-1/2 Top/0.7 Bottom/3.2 Left/2.25 Right/2.25... -
Pb headers
Hi, On my page index.php (which is the default error page of my website), i eventually show an error message which comes from the analysis of... -
Headers for ID CS?
Is there a plug-in or a script for ID CS to do running phonebook style headers (like can be done in Pagemaker)? I have one job I've kept in PM... -
curl and sent headers
is there any way of seeing exactly what headers cURL sent in a transfer, with PHP? -
[PHP] Please dirrect me -- headers ????
Hi, Headers have nothing to do with the <head> tag, the headers are sent before the html page, ie they are not part of the html document, but... -
John #2
Re: Headers already sent?
On Fri, 22 Oct 2004 22:34:14 -0700, A strange species called "Michael
Vilain <vilain@spamcop.net>" wrote:
How do I use this headers_send() to test? I am not so advanced.>In article <hcojn0d4pas4fpgsg8k2fo9uvv6o7rb2bv@4ax.com>,
> John <duki@dafiqak.com> wrote:
>>>> I just wondered if anyone has experienced this error before?
>> "Warning: Cannot modify header information - headers already sent."
>Yes. It's a common mistake if you send anything to the browser then
>send a header(). Use headers_send() to test if this is true and fix
>your logic.
The error it says is on line 52
This is line 52:
header("Location: ". $MM_redirectLoginSuccess );
It doesn't look like it is sending anything further? It is just
registering the session variables and then redirecting.
I put the whole php part of the page at the bottom. I had the same
problem in my registration page but solved it by deleting whitespace.
I tried doing the same with this file but I still have the error.
John
<?php
session_start();
// *** Validate request to login to this site.
//session_start();
?>
<?php
// 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 );
}
}
?>
John Guest
-
Chris Martin #3
Re: Headers already sent?
Here's some info on the headers already sent error.
[url]http://www.parseerror.com/php/headers_already_sent.php[/url]
From what I know of this error (I've gotten it before, sadly, but fixed it
by moving my headers to the top of the page) is that the headers come first!
Not really first, but before any other output. So you can have a 'header'
further down in the page, but it has to be before other output..
It looks like all your code is PHP in that file, why do you use seperate PHP
tags? if you opened one PHP tag at the beginning and closed the same tag at
the very end, (if that's possible for you), maybe it will read all the
headers as one chunk and accept it.
Another weird thing about headers is they hate white space.. so your first
"<?php", make sure there isn't a blank line or a space before it.
Just some thoughts to try, still learning the basics myself!
~Chris
<snip>
Chris Martin Guest



Reply With Quote

