【问题标题】:nothing happens when clicking on my submit button no _POST values单击我的提交按钮时没有任何反应没有 _POST 值
【发布时间】:2010-08-17 18:58:34
【问题描述】:

由于某种原因,当用户单击我的提交按钮时没有任何反应。 html 如下所示:

<td colspan="3">
          <div align="center">
            <input name="Decline" id="Decline" value="Decline" type="submit">
            |
            <input name="Accept" value="Accept" type="submit">
          </div><input name="place" value="user1" type="hidden"><input name="id" value="1" type="hidden">
</td>

我使用 php 从我的数据库中获取此 html 代码。它是我网站上消息系统的一部分,用户可以在其中向其他用户发送消息并接受和拒绝其他用户的请求。我从数据库中收到这样的消息:

while($get = mysql_fetch_object($mysql1)){
                echo $get->message;

当我尝试使用此信息时,$_POST 什么也没显示。

我用这段代码测试过:

            if (!empty($_POST)){
            echo "test"; // nothing shows up!
            }

【问题讨论】:

  • 你有&lt;form method="post"...&gt;吗?

标签: php html post input submit


【解决方案1】:

确保:

  • 你有form标签
  • 并且设置为POST方法
  • 检查var_dump($_POST);

打开错误检查以查看任何可能的错误:

ini_set('display_errors', true);
error_reporting(E_ALL);

【讨论】:

    【解决方案2】:

    您需要将输入字段包装在 FORM 标记中。试试:

    <td colspan="3">
          <div align="center">
            <form method="post" action="/path/to/script.php">
            <input name="Decline" id="Decline" value="Decline" type="submit">
            |
            <input name="Accept" value="Accept" type="submit">
          </div><input name="place" value="user1" type="hidden"><input name="id" value="1" type="hidden">
          </form>
    </td>
    

    【讨论】:

      猜你喜欢
      • 2013-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多