且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP“文档过期";使用后退按钮后

更新时间:2023-12-02 13:42:46

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.