Error - Web Page Has Expired in PHP?

和自甴很熟 提交于 2019-12-11 03:33:09

问题


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?


回答1:


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.




回答2:


redirect the page after receiving the post:

$name = $_POST['name'];
...
header('Location: next.php');



回答3:


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.




回答4:


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.




回答5:


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.



来源:https://stackoverflow.com/questions/1987765/error-web-page-has-expired-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!