PHP Image Button Click Detection

You have a php form with an image for the submit button. I am trying to determine if the submit button was pressed when the page returned. Have tried

$testForm = 'fail'; if (isset($_POST['btnSubmit'])) { $testForm = 'Submit clicked'; } 

button code:

 <input name="btnSubmit" value="Submit" style="float: right;" type="image" src="images/submit.gif" width="181" height="43" alt="Submit Form" /> 

However, it does not seem to work. Try to get the values โ€‹โ€‹of other input elements on the page, and they work fine. Is there any special method for working with image buttons?

+4
source share
1 answer

the image button sends clicked coordinates as [name]_x and [name]_y when sent instead of its value as [name] (some browsers also do this, but not all, and coordinates are set from each browser). that you could just check:

 if (isset($_POST['btnSubmit_x'])) { 
+6
source

All Articles