Image Submit Button within a Form
Solution 1
you can add a hidden field
<input type="hidden" name="action" value="Submit Form">
and in php you can do this
if($_POST['action'] == "Submit Form"){
do something
}
hope this help.
Solution 2
You should use a normal submit
-button and use CSS to replace the button's look with an image. This should work in all browsers.
Solution 3
for image submit button
php code is
if(isset($_POST['btn_opentextbox_X']) || isset($_POST['btn_opentextbox_Y']))
{
//do something
}
Solution 4
The good php code is :
<input type='image' src='../images/blanc.gif' width='596' height='35' onFocus='form.submit' name='btn_opentextbox'/>
if ($_POST["btn_opentextbox_x"]) && ($_POST["btn_opentextbox_y"])
{
......
}
Solution 5
Check for btn_opentextbox_x
or btn_opentextbox_y
instead. (It is actually .
not _
but PHP mangles it).
Some browsers fail to send the value for server side image maps, just the co-ordinates.
And you seem to have forgotten the alt
attribute.
Alternatively, use an actual submit button instead of an image map:
<button type="submit" name="btn_opentextbox" value="submit"><img src="image.png" alt="Submit"></button>
… but note that some versions of IE will send the HTML content instead of the value when it is submitted.
user311509
Updated on July 05, 2022Comments
-
user311509 almost 2 years
I have a form that has Submit button in form of an Image. When user clicks the image button, the image button should play the role of submit button.
Code Sample:
<form action="page.php" method="POST"> <input type="image" name="btn_opentextbox" src="image.png" value="Submit" /> </form>
Handle Submission:
if($_POST['btn_opentextbox']) { //do something }
Surprisingly, the above code used to work perfectly fine in Firefox. However, once i updated my Firefox yesterday, it didn't work at all. I click the button, page gets refreshed and nothing happens. The code also doesn't work in IE.
Note: it works in Chrome.
I want it to work in Firefox, IE, etc.
Any suggestions?