Jump to content

Recommended Posts

Hey guys,

 

So I have this really tricky problem with my login system. I get the cannot modify header information but I havent sent any output ? Here's the error log:

 

[10-Nov-2012 09:38:25 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/sdelkata/public_html/login.php:1) in /home/sdelkata/public_html/login.php on line 16
[10-Nov-2012 09:38:25 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/sdelkata/public_html/login.php:1) in /home/sdelkata/public_html/login.php on line 17

 

and here's the login.php

 

( lines 16 and 17 are originally the setcookie lines )

 

<?php
ob_start();
require("connect_db.php");
$email = mysql_real_escape_string($_POST['email']);
$password = mysql_real_escape_string($_POST['password']);
$msg="";
if (mysql_num_rows(mysql_query("SELECT `id` FROM `blabla` WHERE `email`='$email'"))==0){
$msg = "There is no user named ".wordwrap($email, 33, "<br />\n", 1);
}elseif(mysql_num_rows(mysql_query("SELECT `id` FROM `blabla` WHERE `email`='$email' AND BINARY `password`='$password'"))==0){
$msg = "Wrong password!";
}else{
$id = mysql_result(mysql_query("SELECT `id` FROM `blabla` WHERE `email`='$email' AND `password`='$password'"),0);
setcookie("dd", md5($id),time()+60*60*24*365*10);
setcookie("ff", md5("1"), time()+60*60*24*365*10);
sleep(2);
echo "<script>document.location.reload(true)</script>";
}
if($msg!=""){
sleep(2);
echo "<div id='msgboxred'>$msg</div>";
include "login.html";
}
ob_end_clean();
?>

 

I even added ob_start and ob_end_clean but it still gives me the error. What is weird tho is that it works on my 5.4.4 localhost testing server but doesn't work on the online hosting machine which has 5.3.15 ( php version ).

 

Any help is really appreciated!

Edited by Manixat

okay a little update, all files which have headers modification give me this same error and it always says the headers are sent at line 1 which is always just "<?php". I tried moving the opening php tag a few lines down and the error was at the opening tag again ? Is this a known issue because I don't seem to find where the problem is ?

 

Even this:

 

<?php

header("Content-Type:text/html;charset=utf-8");

 

Is giving me this:

 

[10-Nov-2012 14:03:07 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/sdelkata/public_html/adsubmit.php:1) in /home/sdelkata/public_html/adsubmit.php on line 3

Edited by Manixat

And after you correct how your editor is saving the files, remove the ob_start and ob_end_clean statements from your code. They don't have anything to do with fixing this problem. Also, go into your php.ini on your development system and turn off the output_buffering setting so that your development system matches your live site and you won't waste more time developing php code that won't work when you put it onto your live site.

There's a sticky topic in this forum titled HEADER ERRORS - READ HERE BEFORE POSTING THEM. Pay attention to the part about byte order mark (BOM).

 

Dear god, I've read the whole thing except the last post assuming that the answer wont be there, unfortunately murphy's laws are strongly enforced! Thank you Pikachu2000!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.