问题描述:

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");"

网友答案:

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.

网友答案:

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.

网友答案:

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.

网友答案:

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

网友答案:

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

相关阅读:
Top