PHP “Document Expired” after using the back button

痴心易碎 提交于 2019-11-28 13:03:00

问题


I have a form where I am filing some informations in a wizard. This page is reaching by POST and displayed with Smarty. Once I filed all the informations in, I am using another post to get to another page. Now, the problem is that when I am trying to go back with the BACK button, I am geting the "Document expired" message.

Is than a normal thing while I am using POST or?

I am trying right now to use GET but nothing changes, or my GET is written wrong.

Here is a small schema:

Page 1 -> POST -> Page 2 (wizard) -> POST -> Page 3

When I try to come back from page 3 to page 2, I am geting the doc expired.

Thank you very much for your help regarding my problem.


回答1:


http://en.wikipedia.org/wiki/Post/Redirect/Get

In my opinion, you should do this for every POST, at least in production.

Small example:

if ('GET' == $_SERVER['REQUEST_METHOD']) {
   //display view
}
else if ('POST' == $_SERVER['REQUEST_METHOD']) {
   //process input
   //update session
   header('Location: /next/page/to/view', true, 303);
}

EDIT: Want to point out that this old post was referring to browser submissions. In a RESTful web service you would likely respond with a 201 for POST.




回答2:


Everything is correct. When you push BACK on your Page 3 you are actually trying to go to previous page - this page is generated as a reply to bowser's POST request. To view this page new POST request should be sent and page would be generated relying on POST data.



来源:https://stackoverflow.com/questions/11427136/php-document-expired-after-using-the-back-button

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