0

I checked all answers in different pages and use it, but the error still appears. Please help me.

The error is:

Warning: Cannot modify header information - headers already sent by (output started at /home/iraustor/public_html/copytest/post.php:1) in /home/iraustor/public_html/copytest/post.php on line 57

The URL of form is here: http://iraust.org/copytest/contact.html

And the page that after complete the form is: http://www.iraust.org/copytest/thanks.html (or any other method to shod this message)

It has taken 2 days but answer. Please help me.

"header("Location:$Redirect_Page");"

h7r
  • 4,944
  • 2
  • 28
  • 31
  • possible dublicate of http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php – Debug Diva Feb 21 '15 at 11:56
  • Make sure there is no white space outside of the **php start and end tags.** While a blank line before the ` – SO-user Feb 21 '15 at 11:57
  • Also you do not want empty lines after closing php tags (`?>`). Better even is to simply leave those closing tags away. They only cause problems, it is safe to skip them. – arkascha Feb 21 '15 at 12:02
  • checked it. no space before tags especially the first one –  Feb 21 '15 at 12:06
  • The error says that the output was started at line `1` of `post.php` (post.php:1).... if there's nothing before the opening ` – Mark Baker Feb 21 '15 at 13:34

5 Answers5

0

If you issue headers, like you do for a redirect (setting Location) you MUST be sure that there's no other output before that statement, as PHP will already build the headers (however maybe not yet flushing them to the client) on the first output.

This might be the case for several reasons (unexpected error in some require, a whitespace at the beginning or end of some file, etc, but the error message you have is clear in mentioning where this output started: /home/iraustor/public_html/copytest/post.php:1.

You should double check that there's nothing before the opening and after the closing <?php ... ?> block. This applies to all included or required files in called script.

h7r
  • 4,944
  • 2
  • 28
  • 31
  • In fact, eliminating any trailing `?>` completely can help prevent "invisible" output being sent, for example if you have any newline characters at the end of your script – Mark Baker Feb 21 '15 at 12:07
  • I checked it. no white space in any pages :( –  Feb 21 '15 at 12:13
0

As pointed out by h7r, if you use the header function you cannot print anything before its call.

Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP.

From Header documentation on PHP.net

So, the first thing you should check is the line 57 in your post.php file: there starts the output that causes the error.

Be sure that no output is sent: also a white space or a blank lines is an output and this cause the error.

If you like, you can use the output control functions to buffer the output: in this way you can print what you want but all your outputs aren't sent immediately to browser, so you can use the header function without causing errors.

Community
  • 1
  • 1
Aerendir
  • 6,152
  • 9
  • 55
  • 108
0

Put your code somewhere for us to look at...

Possibly PHP could be outputting an error, or a warning, etc... It might not be you for example.

Chris
  • 546
  • 1
  • 4
  • 18
0

no space before I completely confused! The form is working and the information will be send to e-mail but the error makes feeling nervous for users

0

The problem solved by simple code editor (notpad++) problem: hidden white space and non Unicode characters