View Full Version : button with image doesn't work in POST

Feb 24th, 2010, 05:03 PM
hi, heres my code:

if (isset($_POST['no'])) {$msg = "works!";} else {$msg = "denied!";}

<?php echo "$msg";?>
<form action='java.php' method='POST'>
<input type='image' src='../images/2laida/iconas.ico' name='no' />

The problem is that when I push the button output is denied in spite of works... what is wrong?

Feb 24th, 2010, 05:13 PM
That should be isset($_POST['no_x']) or isset($_POST['no_y'])
See http://www.php.net/manual/en/faq.html.php#faq.html.form-image

Feb 24th, 2010, 05:23 PM
thanks, it worked... But why my name "no" was converted to no_y?

Also, if is post "no_y" - this means pushed, then "no_x" not pushed??

Feb 24th, 2010, 05:36 PM
See http://php.net/manual/en/language.variables.external.php#language.variables.external.form.submit
When the user clicks somewhere on the image, the accompanying form will be transmitted to the server with two additional variables, sub_x and sub_y. These contain the coordinates of the user click within the image.

Feb 24th, 2010, 08:01 PM
ok, thanks.