ganjan
ganjan

Reputation: 7576

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:

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

I tested that with this code:

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

Upvotes: 1

Views: 7537

Answers (2)

Sarfraz
Sarfraz

Reputation: 382776

Make sure that:

  • You have form tag there
  • And it is set to POST method
  • Check with var_dump($_POST);

Turn on error checking to see any possible errors:

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

Upvotes: 3

Ian McIntyre Silber
Ian McIntyre Silber

Reputation: 5663

You need to wrap you input fields in a FORM tag. 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>

Upvotes: 3

Related Questions