The example in this article describes the solution to the failure of header jump using PHP, and is shared with everyone for your reference. The specific method analysis is as follows:
1. Question:
Today’s header("Location: $url"), in the past it was always possible to jump, but today it does not move, it just outputs the result. In the past, I had to confirm and check whether the value of $url was obtained correctly, so add it in front Echo $url; is used for debugging, which results in the header function being invalid.
2. Solution:
When using header("location:test.php") to jump in PHP, please pay attention to the following points:
1. There cannot be a space between location and ":", otherwise an error will occur.//phpfensi.com
2. There cannot be any output before using the header, and there must be no space after the tag "?>" in the include page.
3. The PHP code after the header will also be executed.
No content can be output before PHP's header jumps, because PHP has already sent the HTTP header information to the browser when it starts executing, and changes are no longer allowed after that.
But if you have to process the header information after output, you can use ob_start() ob_end_flush() to cache the content to be sent, and wait until the header continues before sending the content.
Or a simpler way, modify php.ini, find output_buffering=Off and change it to output_buffering=4096.
I hope this article will be helpful to everyone’s PHP programming design.
If you are sure to use the post method to submit, it is a very complicated matter, because PHP is needed to simulate post submission. You can use fsockopen to handle it. I can teach you the specific solution.
Another method is to use the get solution. Relatively speaking, it is super simple. When direct redirection, just convert the data from the post into the get header.
Another solution is to use ajax in the front end. Ajax submits data to b.php on page a. If the return value indicates that the verification is not passed, then the page is transferred to b.php using js. If the return value indicates that the verification is passed, the data of the current post is submitted to c again. .php.
Encoding problem. Change charset=UTF-8 to charset=GB2312