FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Warning: Cannot modify header information





DanielXP
I keep receiving

Quote:
Warning: Cannot modify header information - headers already sent by (output started at /home/rmb/public_html/ads/layout1.php:6) in /home/rmb/public_html/ads/login.php on line 36


From this script.

Code:
<?PHP
session_start();
include("dbconnect.php");
include("layout1.php");
   //Data from Login form
   $username = htmlspecialchars(addslashes($_POST['id']));
   $password = md5(sha1(md5(sha1(md5(md5($_POST['password']))))));
   //Information about the user from the database
   $info = mysql_query("SELECT * FROM `accounts` WHERE `username` = '$username'") or die(mysql_error());
   $data = mysql_fetch_array($info);
   $checkuser = mysql_num_rows($info);
   if($checkuser == '0') {
   //If user does not exist
      echo "User ID does not exist.";
   }elseif($data[password] != $password) {
   //If the wrong password has been entered
      echo "You have enter the wrong password.";
   }elseif($data[banned] == "True") {
   //If the account is banned
      echo "You account has been banned,<br>To appeal against this banned please use the contact form.";
   }elseif($data[verified] == "False") {
   //If the account has not been verified
      echo "Your account has not been verified.";
   }else{
   //Every thing is OK
   $alphanum  = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
   //Create the SID code for the user
   $SID = substr(str_shuffle($alphanum), 0, 16);
   //Update the user IP and SID
   $update = mysql_query("UPDATE `accounts` SET `IP` = '$ip', `SID` = '$SID' WHERE `username` = '$data[username]'") or die(mysql_error());
   //Lets set the sessions
   $_SESSION['id'] = $data[id];
   $_SESSION['password'] = $data[password];
   $_SESSION['SID'] = $SID;
   //All set lets redirect
   header("Location: index.php");
   }
include("layout2.php");
?>


I forget how to fix these.

Thanks,
Daniel
sambhav
Just replace all echo with print. I hope this helps.
MrBlueSky
Make sure the script doesn't output anything before header("Location: index.php");

Check the script and included scripts for empty lines before the <?php directive and remove them.
DanielXP
Thanks

It was the including the layout1 file.

Please lock Smile
sonam
If you have any HTML tag in dbconnect.php or layout1.php, and, of course, echo is one output for php, you cannot use redirection on the end of the script.

Sonam
mOrpheuS
Issue resolved, thread -locked-

Please feel free to PM any staff member if you need this thread re-opened.
Related topics
HELP: setcookie() and header problems
phpbb
phpbb problem....
My upgraded message board
an annoying problem - PLEASE help
phpBB2 Avatar Error
PHP header command
Warning: Cannot modify header information...
Warning: fread(): [problem solved]
phpBB header problem.
Header phase problem
Header redirect problem
Header problems
warning: cannot modify header information
This topic is locked: you cannot edit posts or make replies.    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.