srinivas6203 Posted December 20, 2007 Share Posted December 20, 2007 Warning: Cannot add header information - headers already sent by (output started at c:\apache\htdocs\mysites\includes\header.php:9) in c:\apache\htdocs\netzgatecom1\user_check.php on line 60 I got this type of error frequently my script: <?php include "includes/config.php"; include "includes/header.php"; include "includes/contact_left.php"; ?> <style type="text/css"> .yregfloathelp { border: 1px solid black; /*padding: 5px 5 5 5px; */ background-color:#ffffff; text-align:center; color: black; width: 18em; font-size: 11px; font-family: arial, sans-serif; } </style> <div id="rightSide"><hr /> <div class="title2">.: User login</div> <div class="text2"><p> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td colspan="6" align="center"> <? extract($_POST); $lang_error = "<center>The following errors were found:</center><br>"; $lang_nouser = " <font color='#a10036'>You did not enter your username</font>"; $lang_usernotexist = " <font color='#a10036'>Username does not exist in our dtabase.</font>"; $error_colour = "red"; if (empty ($_POST['username_for'])) { $error = "1"; $info_error .= $lang_nouser . "<br>"; } $checkuser = "SELECT username FROM i_users WHERE username='$_POST[username_for]'"; $resultcheck = mysql_query($checkuser, $db_conn) or die ('query failed'); //if (mysql_num_rows($resultcheck) >0) $row=mysql_fetch_array($resultcheck); if($row['username']!=$_POST['username_for']) { $error = "1"; $info_error .= $lang_usernotexist. "<br>"; } else { $user=$_POST['username_for']; $_SESSION['user']=$user; } if ($error == "1") { $info_notice = "<span style=\"color: " . $error_colour . "; font-weight: bold;\">" . $lang_error . "</span><br>"; if (empty ($submit)) { $info_error = ""; $info_notice = $lang_notice; } } else { header('location:forgot2.php'); } ?> <form action="" method="post" name="c"> <table align="center" border="0" width="50%" cellpadding="0" cellspacing="0" style="border:1px solid #000000;"> <tr bgcolor="#525252"><td colspan="4" align="center"><b><font style="font-size:11px; color:white;">Confirm your Username</font></b></td></tr> <tr><td colspan="4"> </td></tr> <tr><td colspan="4" align="center"><?php echo $info_error ?></td></tr> <tr><td colspan="4"> </td></tr> <tr><td align="center">User Name </td> <td align="center"><sup><font color="red"><b>*</b></font></sup><input type="text" name="username_for" style="border: 1px solid black;width: 150px;background:white;font: 11px verdana, sans-serif;color:#443;padding:3px;margin-bottom:4px;outline:none;"> <!-- popup --> <font class="text" style="cursor:pointer;" onMouseOver="showRollTip('<b><div style=padding-bottom:0px><b></div>Enter correct user name. This is case sensitive.',event,'white', 275, null);" onMouseOut="hideRollTip()"><img src="images/help.gif" border="0" align="baseline" /> </font> <!-- popup end --> </td></tr> <tr align="center" valign="bottom"><td colspan="4"> </td></tr> <tr><td colspan="2" align="center"> <input type="submit" name="submit" value="submit" style="width:80px; font-size:11px; font-family:Arial, Helvetica; color:black; background:white; font-weight:bold; border:1px solid black;" /> </td></tr> <tr><td colspan="4"> </td></tr> </table> </form> </td></tr></table> </p> </div> </div> <? include "includes/footer.php"; ?> can any one help me Quote Link to comment https://forums.phpfreaks.com/topic/82479-solved-cannot-add-header-information-headers-already-sent/ Share on other sites More sharing options...
sKunKbad Posted December 20, 2007 Share Posted December 20, 2007 try adding session_start(); to the top of your file. Quote Link to comment https://forums.phpfreaks.com/topic/82479-solved-cannot-add-header-information-headers-already-sent/#findComment-419280 Share on other sites More sharing options...
sKunKbad Posted December 20, 2007 Share Posted December 20, 2007 I think I spoke too soon. Look at line 60 of user_check.php. What is on that line? Quote Link to comment https://forums.phpfreaks.com/topic/82479-solved-cannot-add-header-information-headers-already-sent/#findComment-419281 Share on other sites More sharing options...
srinivas6203 Posted December 20, 2007 Author Share Posted December 20, 2007 that is redirecetd page which contain url Quote Link to comment https://forums.phpfreaks.com/topic/82479-solved-cannot-add-header-information-headers-already-sent/#findComment-419286 Share on other sites More sharing options...
rajivgonsalves Posted December 20, 2007 Share Posted December 20, 2007 you cannot have a header redirect after sending output to the browser Quote Link to comment https://forums.phpfreaks.com/topic/82479-solved-cannot-add-header-information-headers-already-sent/#findComment-419291 Share on other sites More sharing options...
rajivgonsalves Posted December 20, 2007 Share Posted December 20, 2007 please read http://www.phpfreaks.com/forums/index.php/topic,37442.0.html Quote Link to comment https://forums.phpfreaks.com/topic/82479-solved-cannot-add-header-information-headers-already-sent/#findComment-419295 Share on other sites More sharing options...
rameshfaj Posted December 20, 2007 Share Posted December 20, 2007 use ob_start() infront of the page that generated the error. Try to use less header(...) functions as possible. Quote Link to comment https://forums.phpfreaks.com/topic/82479-solved-cannot-add-header-information-headers-already-sent/#findComment-419298 Share on other sites More sharing options...
srinivas6203 Posted December 20, 2007 Author Share Posted December 20, 2007 Thank you very much to all guys. The problem was solved by using of ob_start() and ob_end_flush() thankyou Quote Link to comment https://forums.phpfreaks.com/topic/82479-solved-cannot-add-header-information-headers-already-sent/#findComment-419359 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.