Page 1 of 1

Warning: Cannot modify header information ERROR

Posted: Fri Mar 21, 2008 5:41 pm
by kelvingeorge
Hi there.. I get this error

Warning: Cannot modify header information - headers already sent by

The code works fine in the main folder.. But the same code in the /admin folder it does not work.. :banghead: It gives the above error... So I put all pages in same main folder without any sub-folders.. Then when session expires this error comes again.. I go back and re-login same page works fine.. Can anyone help me with this??
Some where I read the error was due to UTF-8(w/BOM) encoding... I fixed that part, but still i get same warning.. Help :?

Re: Warning: Cannot modify header information ERROR

Posted: Fri Mar 21, 2008 5:56 pm
by kishanprasad
try to check some where in your program you have echoed some thing before the header ....

may be the echo is coming when the session expires...


i think generally "the headres already sent" will cm due to the echoes ...

Re: Warning: Cannot modify header information ERROR

Posted: Fri Mar 21, 2008 6:04 pm
by kelvingeorge

Code: Select all

$_POST['username'] = stripslashes($_POST['username']);
$hour = time() + 3600;
setcookie(ID_my_site, $_POST['username'], $hour);
setcookie(Key_my_site, $_POST['pass'], $hour);
 
//then redirect them to the members area
header("Location: member.php");
Thats the code... I get error for last three lines

Warning: Cannot modify header information - headers already sent by (output started at.................................. C:\project\websites\bb\check.php line 62
Warning: Cannot modify header information - headers already sent by (output started at.................................. C:\project\websites\bb\check.php line 63
Warning: Cannot modify header information - headers already sent by (output started at.................................. C:\project\websites\bb\check.php line 66

Re: Warning: Cannot modify header information ERROR

Posted: Fri Mar 21, 2008 6:14 pm
by kishanprasad
as it showing the line nos as 62,63,66 can you tell me which line nos is it referring to is it the code that yous en to me or any other

(or)


try to put a ob_start() on the first line itself and ob_endflush() on the last to avoid thhis

Re: Warning: Cannot modify header information ERROR

Posted: Fri Mar 21, 2008 6:25 pm
by kelvingeorge

Code: Select all

62 setcookie(ID_my_site, $_POST['username'], $hour);
63 setcookie(Key_my_site, $_POST['pass'], $hour);
64  
65 //then redirect them to the members area
66 header("Location: member.php");

Re: Warning: Cannot modify header information ERROR

Posted: Fri Mar 21, 2008 11:10 pm
by JAB Creations
With my PHP templating system I keep my headers and non-header includes organized so I never encounter this error...

header.php
header-01-this.php
header-02-that.php
header-03-peanut-butter.php
header-04-jelly.php
includes-00-template-01-head.php
includes-00-template-02-body.php
includes-00-template-03-foot.php
includes-01-xml.php
includes-02-doctype.php
includes-03-css.php
includes-04-js.php