Blogger Information
Blog 33
fans 0
comment 1
visits 43062
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
防止表单重复提交
萝卜温的博客
Original
929 people have browsed it
  • 表单重复提交原因:重复发送同一个请求

  • 情景

1.重复点击按钮(通常是异步请求的情况)
2.提交页面不断刷新
3.点击历史记录
4.点击上一页重复提交
  • 解决方法

1.前端手段,按钮上面做手脚,前提是浏览器允许执行JavaScript
2.后端手段,验证码或者CSRF token
3.数据库手段,设置字段唯一索引
4.PRG(Post-Redirect-Get)流程
  • 保证返回表单页面时,历史填写内容还在

只要 echo '<script>history.back();</script>'; 即可


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post