简体   繁体   English

单击我的提交按钮没有_POST值时没有任何反应

[英]nothing happens when clicking on my submit button no _POST values

For some reason nothing happens when a user click on my submit button. 由于某些原因,当用户单击我的提交按钮时,什么也不会发生。 The html look like this: 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>

I use php to get this html code from my database. 我使用php从我的数据库中获取此html代码。 It's part of an message system on my site where users can send messages to other users and accept and decline the request from other users. 它是我网站上消息系统的一部分,用户可以在其中向其他用户发送消息,并接受和拒绝来自其他用户的请求。 I get the message from the db like this: 我从数据库得到这样的消息:

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

When I try to use this information $_POST shows nothing. 当我尝试使用此信息时,$ _ POST不显示任何内容。

I tested that with this code: 我用以下代码进行了测试:

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

You need to wrap you input fields in a FORM tag. 您需要将输入字段包装在FORM标记中。 Try: 尝试:

<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>

Make sure that: 确保:

  • You have form tag there 你在那里有form标签
  • And it is set to POST method 并设置为POST方法
  • Check with var_dump($_POST); 检查var_dump($_POST);

Turn on error checking to see any possible errors: 打开错误检查以查看任何可能的错误:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM