防止表单被提交两次 [英] Prevent form from being submitted twice
本文介绍了防止表单被提交两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个简单的php表单,像这样:
<?php
if (isset($ _ POST ['myform']))
// email ...
else
//显示表单
问题是,如果我在提交表单后刷新页面,则会提交两次。
如何防止这种情况发生?
解决方案
您应该对页面执行REDIRECT消息,数据插入...和一个返回按钮再次转到窗体(如果你想)...
使用 PHP重定向
使用 标题
功能:
header('Location:http://www.example.com/');
I have a simple php form, like this:
<?php
if(isset($_POST['myform']))
// email...
else
// display form
the problem is that if I refresh the page after I submit the form, it gets submitted twice. How can I prevent this from happening?
解决方案
You should perform a REDIRECT to a page with a message that the data was inserted... and a back button to go to the form again (if you want to)...
To redirect using PHP
use the header
function:
header('Location: http://www.example.com/');
这篇关于防止表单被提交两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文