Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteAfter processing a form’s POST request, redirect with PHP’s header('Location: /thank-you.php', true, 303); and immediately call exit;. Put this handler before any HTML or other output so PHP can still send the redirect headers.
Redirect after a PHP form submission
Handle the POST request at the start of the PHP script: validate and process the submitted values, send a Location header, then stop the request handler.
As an Amazon Associate I earn from qualifying purchases.
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Validate and process the submitted form here.
header('Location: /thank-you.php', true, 303);
exit;
}
?>
The example sends the browser to a same-site thank-you page. The explicit 303 status is useful when a successful POST should be followed by a separate request to retrieve the destination page. See the PHP header() manual for the function’s header and response-code behavior.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Where to put the redirect
Place the POST-handling branch before the page template, layout include, HTML, whitespace outside PHP tags, or any other output. PHP’s manual says header() must run before actual output; even a blank line or output from an included file can prevent the redirect header from being sent.
#1 Best Overall
PHP makes form-submitted information available to the script through external variables such as $_POST. Read and validate the relevant values before taking action; the PHP manual on variables from external sources describes how submitted data is made available.
Choose the redirect status and destination
Use an explicit 303 after POST
In header('Location: /thank-you.php', true, 303);, the third argument sets the response status. A 303 makes the follow-up request a retrieval of the destination page rather than continuing the form submission.
Rank #2
Use PHP’s default Location response when appropriate
If PHP’s default Location behavior is suitable, the shorter form is:
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11header('Location: /thank-you.php');
exit;
PHP documents that a Location header normally produces a 302 response unless a 201 or 3xx status has already been set. An earlier status selection can therefore affect the result; set the intended status explicitly when it matters. The same PHP manual page documents the response-code argument and refers to http_response_code().
Use a deliberate path
A root-relative destination such as /thank-you.php points to a path on the current site. A plain relative URI is interpreted in the context of the requested URL; PHP’s manual notes that older clients may require an absolute URI, even though most contemporary clients accept relative URIs.
Keep the destination fixed or choose it from an allowlist. Do not pass an unchecked form value into the Location header, where it could send visitors somewhere unintended.
Quick Recap
Rank #4
Fix common redirect problems
- “Cannot modify header information” or “headers already sent”: Move the redirect branch before output. Check for rendered HTML, whitespace outside PHP tags, and output from included files.
- The redirect seems to happen, but later code still runs: Put
exit;immediately afterheader()so the current script stops. - The browser goes to the wrong path: Check how the destination is written. Use an intentional root-relative path for a same-site destination, or a known absolute URL if the redirect should leave the site.
- The response status is unexpected: Check whether the script set a status earlier. Pass the desired status to
header()when you need to select it explicitly.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




