![]() |
| HTML | PHP Scripts | Webmaster Tools | Webmaster Forums | Web Hosting | Domain Names | Webmaster Books |
|
|||||||
![]() |
|
|
Thread Tools | Rate this Webmaster Discussion |
|
|
#1 |
|
New Member
Join Date: Jan 2009
Webmaster Discussions: 5
Rep Power: 11 ![]() |
Warning: Cannot modify header information - headers already sent by (output started a
hi,
can anybody help me i this regards. problem is as follows i have a form . here i am getting a value through a file. based on the value i decide the header.but before that i pass a meta data also. <html> <meta http-equiv="refresh" content="2;url=http://localhost/cba.php" /> <?php $handle=fopen('c:/aaa.txt','r'); $a=fgets($handle); fclose($handle); if($a!=0) header( 'refresh: 5; url=http://localhost/abc.php' ); else header( 'refresh: 5; url=http://localhost/cba.php' ); ?> </html> so here once i do this a warning will come up saying "Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\abc.php:7) in C:\Program Files\Apache Group\Apache2\htdocs\abc.php on line 462 " so can anyone give me solution for this.pls |
|
|
|
|
|
#2 |
|
Join Date: Aug 2008
Location: Texas
Webmaster Discussions: 501
Rep Power: 21 ![]() ![]() ![]() ![]() |
Re: Warning: Cannot modify header information - headers already sent by (output start
Sorry about the delayed response. I have been gone for a little while, but I am back now.
When using the header() function in PHP, there can be nothing output to the screen before the function is called. Any HTML is considered output to the screen. What you need to do is move your PHP code to before the HTML as follows: PHP Code:
__________________
Be sure to click the reputation icon to give rep to the person who helped you. For web design/development services, check Silentium Designs. Last edited by jthayne; 05-29-2009 at 12:53 PM. |
|
|
|
|
|
#3 |
|
New Member
Join Date: Mar 2009
Location: Westminster, MD
Webmaster Discussions: 19
Rep Power: 10 ![]() ![]() |
Viola? Why not Bass Fiddle?
|
|
|
|
|
|
#4 |
|
New Member
Join Date: Nov 2009
Webmaster Discussions: 1
Rep Power: 6 ![]() |
Re: Warning: Cannot modify header information - headers already sent by (output start
hi,
i m getting the same "Cannot modify header information - headers already sent in .. " error. There's no white space b4 or after php tags. Here is my code- <? ob_start(); ?> <?php session_start(); if(isset($_POST['login'])) { if(!$fh = fopen('pwd.dat','w')) { do_error_exit('Error opening data file. <br />Please contact the system administrator. <br />Sorry for the inconvenience.'); } $username1[0]= 'kaly'; $username1[1]= crypt('mypassword','rl'); $user_pass_string= implode('=',$username1); fwrite($fh,"$user_pass_string\n"); flock($fh); flush($fh); fclose($fh); $username = $_POST['username']; $password = $_POST['pswd']; $tempwd = crypt($password,'rl'); $fh = fopen('pwd.dat','r'); for($line = fgets($fh); !feof($fh) ; $line = fgets($fh)) { $line = trim($line); $userData = explode("=",$line); if ($userData[0] == $username) $pass = $userData[1]; } fclose($fh); if (crypt($password, $pass) == $pass){ $_SESSION['phplogin'] = true; header('Location: index.php'); exit; } else { ?> <script type="text/javascript"> <!-- alert('Wrong Password, Please Try Again') //--> </script> <?php } } ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title> PHP Login </title> </head> <body> <center> Username:<br> Password:<br> <form method="post" action=""> <input type="username" name="username"> <input type="password" name="pswd"> <input type="submit" name="login" value="Login"> </form> </center> </body> </html> <? ob_flush(); ?> |
|
|
|
|
|
#5 |
|
New Member
Join Date: Nov 2009
Location: USA
Webmaster Discussions: 1
Rep Power: 6 ![]() |
Re: Warning: Cannot modify header information - headers already sent by (output start
I would say Short Tags are not enabled on your host. You can change it in your php.ini file but it is easiest to fix the code.
Change: PHP Code:
PHP Code:
|
|
|
|
|
|
#6 |
|
Join Date: Aug 2008
Location: Texas
Webmaster Discussions: 501
Rep Power: 21 ![]() ![]() ![]() ![]() |
Re: Warning: Cannot modify header information - headers already sent by (output start
Actually what needs to happen, is you need to move
PHP Code:
My recommendation is to move it just before this line: HTML Code:
<script type="text/javascript">
__________________
Be sure to click the reputation icon to give rep to the person who helped you. For web design/development services, check Silentium Designs. |
|
|
|
![]() |
| Bookmarks |
| Tags |
| header, modify |
| Thread Tools | |
| Rate This Thread | |
|
|
Similar Webmaster Discussions
|
||||
| Thread | Webmaster Discussion Starter | Forum | Replies | Last Post |
| mypsace modify friends help? | ineedhelpmyspace | Myspace Forum | 0 | 06-19-2009 12:17 PM |
| Premature end of script headers error | madan9999 | CGI Perl Forum | 1 | 08-16-2006 02:16 PM |
| Question about Headers (I think) | sshadow | HTML Forum | 5 | 04-10-2001 02:48 PM |