点击浏览器“返回”按钮导致详细信息保存
我收到了一位用户的报告,每当他们编辑个人资料详细信息时,如果他们在浏览器上点击“返回”,他们可能所做的任何更改都会被保存,而这些更改只能由他们单击“保存”来保存” 页面中的按钮。
发生这种情况的可能原因有哪些,我该如何预防?
I've had a report from a user that whenever they go to edit their profile details, if they hit "Back" on their browser, any changes they may have made are saved, when they should only be saved by them clicking the "Save" button in the page.
What possible reasons are there for this happening, and how can I prevent it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来像是表单重新提交问题。看看此处,看看这是否为您指明了正确的方向
Sound like a form resubmission issue. Have a look here and see if that points you in the right direction
如果用户双击“提交”按钮并触发两个表单提交,也会发生这种情况。
解决方案是在表单中添加一个字段,该字段是每次加载表单时生成的唯一参考 ID。
提交表单时,您的程序应记录此 ID 已被使用(可能将其存储在用户会话中),并拒绝任何使用相同 ID 发布表单的后续尝试。
实现此功能的方法有很多,因此我不会给您提供代码示例,但它应该相当简单。
希望有帮助。
This sort of thing can also happen if the user double-clicks on the 'submit' button and triggers two form submissions.
The solution to it is to have a field in the form which is a unique reference ID which is generated each time the form is loaded.
When the form is submitted, your program should make a note that this ID has been used (maybe store this in the user's session), and reject any subsequent attempts to post a form with the same ID.
There are many ways of implementing this, so I won't give you a code example, but it should be fairly straightforward.
Hope that helps.