views:

32

answers:

2

Hi. 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!
            }
+1  A: 

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>
Ian Silber
+1  A: 

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);
Sarfraz