PHP“文档过期";使用后退按钮后 [英] PHP "Document Expired" after using the back button
问题描述
我有一个在向导中归档一些信息的表格. POST到达此页面,并与Smarty一起显示.将所有信息归档后,我将使用另一篇文章转到另一页.现在的问题是,当我尝试使用返回"按钮返回时,会收到文档已过期"消息.
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.
在使用POST时,这是正常现象吗?
Is than a normal thing while I am using POST or?
我现在正在尝试使用GET,但是没有任何变化,或者我的GET错误.
I am trying right now to use GET but nothing changes, or my GET is written wrong.
这是一个小模式:
Page 1 -> POST -> Page 2 (wizard) -> POST -> Page 3
当我尝试从第3页回到第2页时,我的文档已过期.
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.
推荐答案
http://en.wikipedia.org/wiki/Post/Redirect/Get
我认为,至少在生产环境中,您应该为每次 POST进行此操作.
In my opinion, you should do this for every POST, at least in production.
小例子:
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);
}
想指出的是,这个旧帖子是指浏览器提交的内容.在RESTful Web服务中,您可能会用201来响应POST.
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.
这篇关于PHP“文档过期";使用后退按钮后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!