When an user submits a form and everything worked, he will get a success message with a META REFRESH of 3 seconds. Then the page refreshes, but when I click the refresh button or F5, the page asks me if I want to resubmit, meaning that META REFRESH didn’t actually redirect and clear everything.
Is there a way to prevent data resubmission when using META REFRESH?
I could’ve used header('Location: somewhere.php');, but I wouldn’t be able to show a success message with it.
I am using META REFRESH with PHP headers, like this header("refresh:3;url=" . $home_action);
You should use
header('location: somewhere.php?message=success')and on the pagesomewhere.phpyou can check for existence of themessageget variable and output a success message if you see one.This is the way that it usually gets done. Another way is to set a
$_SESSIONvariable and check for that onsomewhere.php. If it exists remember to remove it from the session.