PHP Redirection with POST Parameters
The query posed concerns redirecting users from one webpage to another while retaining POST parameters. The original method, which involved transferring GET parameters to POST parameters through a form, was deemed suboptimal, especially for users with JavaScript disabled. The question sought a pure PHP-based solution for POST parameter transfer during redirection.
The answer revealed that it is possible to header redirect a POST request, including its parameters. This is achieved by explicitly setting the HTTP status code to 307 before the redirect location.
header('HTTP/1.1 307 Temporary Redirect');
header('Location: anotherpage.php');
However, it's crucial to note that, according to the HTTP specification, the user agent should prompt the user for confirmation before resubmitting the POST information to the new URL. In practice, while some browsers may skip this step, Firefox presents a confirmation popup. This behavior may present potential confusion for end users in certain use cases.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3