防止多次提交

时间:2013-03-06 14:30:31

标签: php html http-get

我有一个向自己发送数据的页面,即使用PHP_SELF

页面刷新时,即页面重新加载时,我放置两个按钮 - Refresh Again,我在哪里 使用PHP_SELF再次使用发送数据。 - 弹出一个警告框,要求确认,通常在日期再次发送到页面时发生。

第二个按钮的目的 - Reload without sending data,必须重新加载页面。

没有出现上面的弹出框,即没有发送数据。

有没有办法在数据再次发送到之前清除数据 服务器还是页面?

我通过$_GET发送数据。

我检查是否收到如下数据:

if(isset($_GET['getVariable']))

/* I place the buttons here, in a form, the action parameter of which points to the same page, i.e. `PHP_SELF`

1 个答案:

答案 0 :(得分:2)

您可以在不提交新表单的情况下进行刷新:

<form name="refresh" action="" method="post">
  <input type="submit" value="Refresh without submitting" />
</form>

或使用JavaScript刷新当前按钮。

<input type="button" value="Refresh without submitting" onclick="location.reload();" />

另外,请使用action=""代替PHP_SELF