All articles
Why Post/Redirect/Get still matters
PHPWeb Security
The problem
When a form POSTs and the server answers with a page, pressing refresh re-sends the form. That is how duplicate orders and duplicate comments happen.The fix
After handling the POST, redirect to a GET URL. The browser then reloads a harmless page.if ($_SERVER["REQUEST_METHOD"] === "POST") {
save($_POST);
header("Location: /thanks.php", true, 303);
exit;
}Use a 303 status so the browser always switches to GET.