I\'m trying to refresh a page without sending POST from the previous time.
I\'ve tried
window.open(\"postme.php?r=t\", \"_self\");
Got this to work...
window.location = "postme.php?r=t";
Well.. late too I suppose, but then it could help someone. I used :
window.location.href = window.location.href;
In replacement of location.reload(); this will refresh the page without prompting user to resend information.
If you want to avoid having refresh reporting data (for any reason, including the user clicking the reload button) then use the POST-REDIRECT-GET pattern.
Redirect the user to the same page after you're finished using their POST data.
$URI = $_SERVER['REQUEST_URI'];
if(!empty($_POST)){
//magic
header("location:$URI");
}
Now when you refresh, it won't have POST data to resubmit.
i know this is way late, and hope it applies: i had the same problem where when someone is confirming their inventory selection, it then emails the order [or subtracts from inventory database] then displays their order. then if they refresh, it resubmits the data. so i added a session_destroy(). but then when they refresh, there're lots of errors.
SO - i divided the code into [a]email the order/subtract from the inventory database, then [b]used a javascript "document.location.href='nextPage.php'" because i sometimes have problems using PHP's "location(nextpage.php)". anyway, it emails the info, then goes to the page that displays it. then one can refresh all they want and all that happens is it displays over and over.
hope that helps!
You could try:
window.location.reload(true); //true sets request type to GET