Reputation: 41
I have six pages for a registration form in my PHP project.
In between any of the page if I press the back button from the explorer bar I get the error:
Webpage has Expired
I am using $_POST
to submit the data. I can't understand why this occurs?
Upvotes: 2
Views: 4626
Reputation: 1272
The real answer is "If you hit the back button, the browser doesn't send the POST request you originally sent when you first visited that page", what you might want to do if you are doing a multi-step form is either do it with AJAX, or use GET instead of POST.
Upvotes: 0
Reputation: 344431
That message has to do with the way IE handles pages generated from POST data.
In general, to avoid this problem you have to make sure that in the back history, the user will never be able to land on a page that was generated from a POST request. As jspcal suggested, your POST response should be a redirect to another page requested by a GET. This is also considered best-practice since it reduces the risk of submitting a form twice.
Upvotes: 4
Reputation: 51914
redirect the page after receiving the post:
$name = $_POST['name'];
...
header('Location: next.php');
Upvotes: 3
Reputation: 945
This always happens on certain browsers (you're probably using internet explorer) when you are trying to re-submit post data by going back in the browser history. Many browsers though (Firefox for example) give you the opportunity to submit the post data again when you go back in history.
Upvotes: 2
Reputation: 58097
Have you tried "$_GET"? This probably happens because the POST info comes from the page before and isn't really saved anywhere for longer than the transition of pages, whereas GET uses the URL to send the info, so the information is stored somewhere. I would see what happens with GET.
Upvotes: 0