views:

39

answers:

2

I can't figure out why...

This works:

<?php
    if($_POST['test']) echo "posted";

?>

<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <input type="submit" name="test" />
</form>

and this doesn't:

<?php
    if($_POST['test']) echo "posted";

?>

<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <input type="image" name="test" src="images/button.submit.png" />
</form>
+4  A: 

When you post via an image the x/y coordinates that were clicked on are sent instead. Check $_POST['test_x'] and $_POST['test_y']

Michael Mrozek
Correct. To be clear, there is no `$_POST['test']` only `$_POST['test_x']` and `$_POST['test_y']` .
Ramblingwood
+2  A: 

Image inputs only post the x and y co-ordinates of where the click happened, not (necessarily) a value. If you really want to use an image in this way, you may want to add a hidden field too.

graphicdivine