且构网

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

提交表单后防止重新加载页面中的重复数据

更新时间:2022-10-23 09:31:54

一个常见的解决方案是处理POST重定向到自己的服务器端脚本 - 浏览器将使用GET请求来获取页面,可以安全地重新加载。或者,您可以将POST数据复制到SESSION数据并引用它以提供反馈,例如已发送消息或已提交订单或已保存设置。


Possible Duplicate:
How to prevent duplicate posts via a browser refresh?

I have a simple html form to give some info from users and register it two database. all things are OK. but the problem when begin that user press F5 or refresh the page; in this case previous info again register to database and create duplicate.

my question from you is how I can delete headers after register info in database

A common solution is for the server-side script that handles the POST to redirect to itself - the browser will then use a GET request to fetch the page, which can be reloaded safely. Optionally, you can copy the POSTdata to SESSIONdata and refer to it to provide feedback such as "Message sent" or "Order submitted" or "Settings saved".