【问题标题】:Prevent multiple submissions防止多次提交
【发布时间】:2013-02-21 09:36:07
【问题描述】:

我有一个向自身发送数据的页面,即使用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`

【问题讨论】:

  • 我会将它发送到一个“空”的 php 页面,该页面只会使用 header('Location: '. $_SERVER['HTTP_REFERER']); 将其发送回上一页,但这没有任何意义,哈哈,
  • 使用 POST 而不是 GET,因为您正在处理数据(而不是显示数据)
  • 这不是那么敏感的事情。因此求助于 $_GET。
  • <input type='button' onClick='refreshPage()'> forum.jquery.com/topic/onclick-goto-a-url-how 怎么样
  • <input type="reset" />tizag.com/htmlT/htmlreset.php有什么问题?

标签: php html http-get


【解决方案1】:

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

<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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-11-29
    • 2014-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-16
    相关资源
    最近更新 更多