Search
Left Quote    Nearly all men can stand adversity, but if you want to test a man's character, give him power.
- Abraham Lincoln    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: headers already sent!! Problem
  This user is online  Guest
  Subject: "headers already sent!! Problem" Posted: @ 9:24 pm on Mar 27 2006   
Unregistered
Hi, I'm new in coding but I've almost done the member system tutorial but I have this error:
"Warning: Cannot send session cache limiter - headers already sent (output started at /log.php:3)&quo t;

I use "sessio n_start( );" once, is there any comment..

Qais

    Viewed: 32,368 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: headers already sent!! Problem" Posted: @ 11:11 pm on Mar 27 2006    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Yes, did you skip the part about using ob_start(); as the first line of your script (right after <? )?




-bs0d | AllSyntax.com

    Viewed: 29,819 Times | Reply to This | To top
  This user is online  Guest
  Subject: "re: headers already sent!! Problem" Posted: @ 2:19 am on Mar 28 2006    
Unregistered

Ohh, Only this!! I thought it is a big deal to correct it.. but I was wrong; the big deal acctually is learning this language.

Thank you admin. it works just fine..

best Regards.



    Viewed: 29,814 Times | Reply to This | To top
  This user is offline  Denzel
  Subject: "Another headers... =(" Posted: @ 3:55 pm on Jul 10 2006    
Member #: 163
Rank: User - (14)
Since: 05/07/06
Posts: 14
From: Portugal - Aveiro

Warning: Cannot modify header information - headers already sent by (output started at c:\programas\ easyphp1-8\www \logar.php:9) in c:\programas\ easyphp1-8\www \logar.php on line 27

Warning: Cannot modify header information - headers already sent by (output started at c:\programas\ easyphp1-8\www \logar.php:9) in c:\programas\ easyphp1-8\www \logar.php on line 43

Im having this problems and im geting realy pissed of with this...
Can someone help me? Ty..




brunoliveirapt@
hotmail.com |     Viewed: 29,564 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: headers already sent!! Problem" Posted: @ 10:43 pm on Jul 10 2006    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

hey as posted in this thread just 1 post above yours, I say: use ob_start(); as the very first line of your script.




-bs0d | AllSyntax.com

    Viewed: 29,557 Times | Reply to This | To top
  This user is offline  Denzel
  Subject: "re: headers already sent!! Problem" Posted: @ 2:03 pm on Jul 11 2006    
Member #: 163
Rank: User - (14)
Since: 05/07/06
Posts: 14
From: Portugal - Aveiro

i did it! just copy from the tutorial and posted... Still appears tha messages... =/




brunoliveirapt@
hotmail.com |     Viewed: 29,550 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: headers already sent!! Problem" Posted: @ 5:10 pm on Jul 11 2006    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Ok then, show me the code of logar.php

Keep in mind, if you have the code in logar.php but are including logar.php in another file, like index.php, then ob_start(); needs to be the 1st line of the file that you're including the login script in.




-bs0d | AllSyntax.com

    Viewed: 29,546 Times | Reply to This | To top
  This user is offline  Denzel
  Subject: "re: headers already sent!! Problem" Posted: @ 1:03 am on Jul 12 2006    
Member #: 163
Rank: User - (14)
Since: 05/07/06
Posts: 14
From: Portugal - Aveiro


Code:


<?

ob_start();
require_once($_ SERVER['DOCUME NT_ROOT'].'/d b_connect.php' );

if(isset($_SESS ION['username ']) && isset($_SESSION ['password']) ) {
//REDIRECT TO USERS PROFILE...
header("L ocation: http://localhos t"; } //end if logged in

//IF SUBMIT BUTTON PRESSED
if(isset($_POST ['submit'])) {

if(!$_POST['us ername']) die("Erro r: You must enter your username before logging in.";
if(!$_POST['pa ssword']) die("Erro r: You must enter your password before logging in.";

//set cookie if checked
if(!empty($_POS T['stay_in']) ) {
$joined =''.$_POST[' username'].'[ ]'.md5($_POST[ 'password']). '';
setcookie('log in_cookie', $joined, 2147483647, '/', '.www.yoursite .com');
} //end if

//verify user...
$get_user = mysql_query(&q uot;SELECT * FROM `members` WHERE username = '".$_POS T['username'] ."' AND

user_password = '".md5($ _POST['passwor d'])."' ";
$q = mysql_fetch_obj ect($get_user);
if(!$q) die("Logi n Failure: An error occured, please verify your username and password are correct."< img src=/forums/ima ges/smilies/win k.gif border=0>;

//set session variables
$_SESSION['log ged_in'] = 1;
$_SESSION['use rname'] = $_POST['userna me'];
$_SESSION['pas sword'] = $_POST['passwo rd'];
session_write_c lose();

header("L ocation: http://localhos t/Headpage.php ";
exit;

} else {
//show login form
?>
<form name="log in" method="p ost" action="& lt;? $_SERVER['PHP_ SELF']; ?>"> ;
<table>
<tr>
<td>Usern ame:<input type="tex t" id="usern ame" name="use rname"> ;</td>
</tr>
<tr>
<td>Passw ord:<input type="pas sword" id="passw ord" name="pas sword"> ;</td>
</tr>
<tr>
<td>Submi t: <input type="sub mit" value="Su bmit" name="sub mit" id="submi t">< ;/td>
</tr>
<tr>
<td>Remem ber? <input type="che ckbox" name="sta y_in[]" checked=" yes">& lt;/td>
</tr>
</table>
</form>
<?
}//end else
?>



Edited at 03:10:52 am on 07/12/06


brunoliveirapt@
hotmail.com |     Viewed: 29,542 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: headers already sent!! Problem" Posted: @ 11:28 pm on Jul 12 2006    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Denzel,
I dont see an error in the code. Did you read through the tutorial and see how each part of the code works?

Also, you didnt answer my question from before, are you including this script from another file?




-bs0d | AllSyntax.com

    Viewed: 29,533 Times | Reply to This | To top
  This user is online  Guest
  Subject: "re: headers already sent!! Problem" Posted: @ 11:41 pm on Jul 12 2006    
Unregistered

I guess not... What u meen by including? Something like making a link to the page? No its an empty page nothing pointing at him...
Still it makes the same error..



    Viewed: 29,530 Times | Reply to This | To top
  This user is offline  Denzel
  Subject: "re: headers already sent!! Problem" Posted: @ 11:43 pm on Jul 12 2006    
Member #: 163
Rank: User - (14)
Since: 05/07/06
Posts: 14
From: Portugal - Aveiro

Hum that was me sorry =)




brunoliveirapt@
hotmail.com |     Viewed: 29,527 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: headers already sent!! Problem" Posted: @ 2:01 am on Jul 13 2006    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

What I mean is, say you have : yoursite.com/fo rums/signup.php

well, then in signup.php you include the login php code which is in a seperate file (logar.php) like this:

include($_SERV ER['DOCUMENT_R OOT'].'/forum s/logar.php');

if this was the case, then signup.php may need ob_start(); as the 1st line.

Im concerned for the fact that you simply copy and pasted the code and expected it to work. You need to read the tutorial word for word and setup your site as described. Delete the code you have and start over. Its not like you're losing anything, because what you need is all in the tutorial. Read it, apply it and lets see if we can get rid of this. Because every other person that has posted the same problem has been fixed by using ob_start();




-bs0d | AllSyntax.com

    Viewed: 29,524 Times | Reply to This | To top
  This user is offline  Denzel
  Subject: "re: headers already sent!! Problem" Posted: @ 9:03 am on Jul 13 2006    
Member #: 163
Rank: User - (14)
Since: 05/07/06
Posts: 14
From: Portugal - Aveiro

Dude i copy paste but i read and tryied to understand all things 1 by 1!! A tutorial is to learn! Not to just copy i know.. =) Im about to try something.. ill try and then tell something..
Ty for the tips




brunoliveirapt@
hotmail.com |     Viewed: 29,521 Times | Reply to This | To top
  This user is online  Guest
  Subject: "re: headers already sent!! Problem" Posted: @ 3:14 pm on Jul 14 2006    
Unregistered

try adding ob_start() to THE VERY TOP

you have

<?

ob_start()


try

<? ob_start()

instead



    Viewed: 29,499 Times | Reply to This | To top
  This user is offline  Denzel
  Subject: "re: headers already sent!! Problem" Posted: @ 11:56 pm on Jul 16 2006    
Member #: 163
Rank: User - (14)
Since: 05/07/06
Posts: 14
From: Portugal - Aveiro

Ty i already did it! it was a litle mistake.. I having some probles with the variables but i think i can fix it




brunoliveirapt@
hotmail.com |     Viewed: 29,480 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: headers already sent!! Problem" Posted: @ 3:17 am on Jul 17 2006    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

So did it work?




-bs0d | AllSyntax.com

    Viewed: 29,477 Times | Reply to This | To top
  This user is offline  Denzel
  Subject: "re: headers already sent!! Problem" Posted: @ 2:05 pm on Aug 22 2006    
Member #: 163
Rank: User - (14)
Since: 05/07/06
Posts: 14
From: Portugal - Aveiro

Yup all functionable!! Ty for the help dude




brunoliveirapt@
hotmail.com |     Viewed: 29,345 Times | Reply to This | To top
  This user is offline  boy
  Subject: "re: headers already sent!! Problem" Posted: @ 12:20 pm on May 05 2008    
Member #:
Since: 01/01/70
Posts:

I have the same warning messages. Can you tell me how to fix this, please?
When you type your username and password in login.php page, what is it supposed to happen next?
In my page only shows the 2 warning message...




    Viewed: 25,283 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: headers already sent!! Problem" Posted: @ 5:17 pm on May 05 2008    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

use ob_start(); as the 1st line of your page (even before <HTML> like this:
Code:

<? ob_start(); ?>
<HTML>




-bs0d | AllSyntax.com

    Viewed: 25,264 Times | Reply to This | To top
  This user is offline  boy
  Subject: "re: headers already sent!! Problem" Posted: @ 7:04 pm on May 05 2008    
Member #:
Since: 01/01/70
Posts:

my login.php code looks like this, but still got 2 warning messages..

<? ob_start();
require_once($_ SERVER['DOCUME NT_ROOT'].'/d b_connect.php' );

if(isset($_SESS ION['username ']) && isset($_SESSION ['password']) ) {
//REDIRECT TO USERS PROFILE...
header("L ocation: http://localhos t/login.php&qu ot;
} //end if logged in

//IF SUBMIT BUTTON PRESSED
if(isset($_POST ['submit'])) {

if(!$_POST['us ername']) die("Erro r: You must enter your username before logging in.";
if(!$_POST['pa ssword']) die("Erro r: You must enter your password before logging in.";

//set cookie if checked
if(!empty($_POS T['stay_in']) ) {
$joined =''.$_POST[' username'].'[ ]'.md5($_POST[ 'password']). '';
setcookie('log in_cookie', $joined, 2147483647, '/', '.www.yoursite .com');
} //end if

//verify user...
$get_user = @mysql_query(& quot;SELECT * FROM `members` WHERE username = '".$_POS T['username'] ."' AND

user_password = '".md5($ _POST['passwor d'])."' ";
$q = @mysql_fetch_ob ject($get_user) ;
if(!$q) die("Logi n Failure: An error occured, please verify your username and password are correct."< img src=http://www. allsyntax.com/f orums/images/sm ilies/wink.gif border=0>;

//set session variables
$_SESSION['log ged_in'] = 1;
$_SESSION['use rname'] = $_POST['userna me'];
$_SESSION['pas sword'] = $_POST['passwo rd'];
session_write_c lose();

header("L ocation: http://localhos t:8888/login.ph p";

} else {
//show login form
?>
<form name="log in" method="p ost" action="& lt;? $_SERVER['PHP_ SELF']; ?>"> ;
<table> <tr>
<td>Usern ame:<input type="tex t" id="usern ame" name="use rname"> ;</td>
</tr>
<tr>
<td>Passw ord:<input type="pas sword" id="passw ord" name="pas sword"> ;</td>
</tr>
<tr>
<td>Submi t: <input type="sub mit" value="Su bmit" name="sub mit" id="submi t">< ;/td>
</tr>
<tr>
<td>Remem ber? <input type="che ckbox" name="sta y_in[]" checked=" yes">& lt;/td>
</tr>
</table>< br /> </form> <?
}//end else

?>




    Viewed: 25,260 Times | Reply to This | To top
  This user is offline  David1159
  Subject: "re: headers already sent!! Problem" Posted: @ 8:06 pm on May 05 2008    

Member #: 526
Rank: User - (81)
Since: 12/27/07
Posts: 81
From: usa

Both of your redirects, are sending you back to your login.php

Both of yours lines of code.

Code:


header("L ocation: http://localhos t/login.php&qu ot;
header("L ocation: http://localhos t:8888/login.ph p";


Set the headers to the page you want your logged in members to be redirected to.



Edited at 08:26:35 pm on 05/05/08


Coding is simply CST... Combining $hit Together. We make different $hit to run in unison correctly.

    Viewed: 25,249 Times | Reply to This | To top
Viewing Page: 1 of 2


1 | 2 |
Next »





"AllSyntax.com" Copyright © 2002-2017; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank