Jump to content

Warning: Cannot modify header information


eaglelegend

Recommended Posts

I am getting this on one of my pages:

Warning: Cannot modify header information - headers already sent by (output started at /misc/39/000/171/334/2/user/web/eaglelegend.com/header.php:5) in /misc/39/000/171/334/2/user/web/eaglelegend.com/members.php on line 3

 

This is members.php:

<?php
if($_COOKIE['elv2']=="") {
	Header("Location: http://www.eaglelegend.com/index.php?message=You are logged out! Please log back in!");
}

$creditsSQL = mysql_query("SELECT * FROM `members` WHERE `username`='{$_COOKIE['ELv2']}'");
while($creditsROW = mysql_fetch_array($creditsSQL)) {
	$MONEY = $creditsROW["money"];
	$POINTS = $creditsROW["points"];
	$FROZEN = $creditsROW["frozen"];
}

if($FROZEN==1) {
	print "<b>YOUR ACCOUNT IS FROZEN! PLEASE CONTACT THE SITE ADMIN. YOU HAVE BEEN LOGGED OUT!</b>";

setcookie("ELv2",null);
}
?>

Link to comment
https://forums.phpfreaks.com/topic/99535-warning-cannot-modify-header-information/
Share on other sites

Maybe it's the spaces in your url. You also need and exit() statement after the header() call. I also changed your check for an empty string to use empty().

 

<?php
if (empty($_COOKIE['elv2']))
{
$url = rawurlencode("message=You are logged out! Please log back in!");
header("Location: http://www.eaglelegend.com/index.php?$url");
exit();
}
?>

Read the error message -

 

output started at ..../header.php:5

 

Your header.php file is sending output to the browser at or before line 5 and this is preventing the header() statement in members.php on line 3 from working.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.