Jump to content

Cannot Modify Header Information Error


netpants

Recommended Posts

I read the sticky but I cannot figure what is wrong and what ordr things should be in in this little script. Here is the error.

 

Warning: Cannot modify header information - headers already sent by (output started at /home/battle/domains/battlefordomination.com/public_html/userhead.php:2) in /home/battle/domains/battlefordomination.com/public_html/userhead.php on line 14

 

Here is the code.

 

<?php
if(!isset($HTTP_COOKIE_VARS['Username']) || !isset($HTTP_COOKIE_VARS['Password']) || strlen($HTTP_COOKIE_VARS['Username'])<5) {
header("Location: login.php?error=iv"); exit();
}

$result = mysql_query("SELECT * FROM userinf WHERE username='".$HTTP_COOKIE_VARS['Username']."' AND password='".$HTTP_COOKIE_VARS['Password']."' ", $db);
if(!mysql_num_rows($result)) { header("location: login.php?error=na"); exit(); }
else {
$userinf = mysql_fetch_array($result);
if($userinf['bactiv']=='0') { header("Location: login.php?error=bf"); exit(); }
if($userinf['bactiv']=='2') { header("Location: login.php?error=bl"); exit(); }
if($userinf['bactiv']>='3') { header("Location: login.php?error=uk"); exit(); }
if($userinf['holiday']>1) { header("Location: login.php?error=hl&data=".$userinf['holiday']); exit(); }
else if($userinf['holiday']==1) {
	mysql_query("UPDATE userinf SET holiday=0 WHERE username='".$HTTP_COOKIE_VARS['Username']."' AND password='".$HTTP_COOKIE_VARS['Password']."' ", $db);
	$userinf['holiday']=0;
}

if($userinf['mdelete']) {
	mysql_query("UPDATE userinf SET mdelete=0 WHERE username='".$HTTP_COOKIE_VARS['Username']."' AND password='".$HTTP_COOKIE_VARS['Password']."' ", $db);
	$userinf['mdelete']=0;
	$b_cmdelete = true;
}
}
mysql_query("UPDATE userinf SET ltime='".time()."' WHERE username='".$HTTP_COOKIE_VARS['Username']."' AND password='".$HTTP_COOKIE_VARS['Password']."' ", $db);
?>

 

If someone could give me some hints as to what is going on I would greatly appreciate it.

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

Where is the file this is being included in. If you want help post code for all files involved. Chances are the editor you are using is outputting a character that you do not know OR your file is outputting data to the screen.

 

If you want help post more code.

Here is the code from the login page this is where the information is inputted in to give me this error.

 

<?php
if(isset($HTTP_POST_VARS['usern'])) {
$usern = strip_tags($HTTP_POST_VARS['usern']);
$passw = strip_tags($HTTP_POST_VARS['passw']);
setcookie("Username",$usern);
setcookie("Password",$passw);
header("Location: member.php");
exit();
}
require('dblogon.php');
require('std_l.php');
?>
<center>
<?php
if(isset($_GET['error']) && $_GET['error']=="hl") {
if(isset($_GET['data']) && is_numeric($_GET['data'])) {
	echo "Your account is in holiday mode, and cannot be accessed for another ".$_GET['data']." ticks.<br>\n";
} else {
	echo "Your account is in holiday mode, and cannot be accessed.<br>\n";
}
}
?>
<table border="0" cellpadding="2px" cellspacing="0" width="300px">
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<?php
if(isset($_GET['forget']) && $_GET['forget']==1) {
echo "<tr><td>Email address</td><td><input type=\"text\" name=\"email\" maxlength=\"200\" class=\"sdinp\"></td></tr>\n";
echo "<tr><td></td><td><input type=\"submit\" value=\"Recover\" class=\"sdbut\"></td></tr>\n";
} else if(isset($_POST['email'])) {
$result = mysql_query("SELECT email,username,password FROM userinf WHERE email='".$_POST['email']."' ", $db);
if(mysql_num_rows($result)) {
	$retval = mysql_fetch_array($result);
	$msg = "Thank you for joining the Battle for Domination.\n \nYour account information is as follows:\n \n";
	$msg.= "Username: ".$retval['username']."\n";
	$msg.= "Password: ".$retval['password']."\n \n To login please go to <a href=Http://www.battlefordomination.com/login.php>www.battlefordomination.com</a>";
            mail($retval['email'],$title.": Account info",$msg,"From: $title");
	echo "<tr><td align=\"center\"><b>Your account information has been emailed to you!</b></td></tr>\n";
} else { echo "<tr><td align=\"center\"><b>Account not found!</b></td></tr>\n"; }
} else {
echo "<tr><td>Username</td><td><input type=\"text\" name=\"usern\" maxlength=\"50\" class=\"sdinp\"></td></tr>\n";
echo "<tr><td>Password</td><td><input type=\"password\" name=\"passw\" maxlength=\"50\" class=\"sdinp\"></td></tr>\n";
echo "<tr><td></td><td><input type=\"submit\" value=\"Log me in\" class=\"sdbut\"></td></tr>\n";
echo "<tr><td colspan=\"2\"> </td></tr>\n";
echo "<tr><td colspan=\"2\" align=\"center\"><a href=\"login.php?forget=1\">[ forgotten password? ]</a></td></tr>\n";
}
?>
</form>
</table>
</center>
<?php require('std_r.php'); ?>

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.