简体   繁体   中英

Cannot modify header information (connot detect header)

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 include d or require d 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

简单的代码编辑器(notpad ++)问题解决了这个问题:隐藏的空白区域和非Unicode字符

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM