Jump to content

[SOLVED] Image as Submit Button won't work...


webmaster1

Recommended Posts

Hi All,

 

I'm using an image as submit that has a mouseover effect but it doesn't trigger my php code when clicked;

 

<input name="submit" id="submit" type="image" alt="Send Message" 
src="images/general_sendmessage1.jpg" 
srcover="images/general_sendmessage2.jpg" 
srcdown="images/general_sendmessage1.jpg" 
border="0">

 

It works fine when I use this:

 

<input name="submit" id="submit" type="submit"/>

 

Any ideas why its not working? i'm more interested in understanding whats going wrong rather than its fix.

                                                     

Link to comment
https://forums.phpfreaks.com/topic/152653-solved-image-as-submit-button-wont-work/
Share on other sites

Righto. So far I've found out its an IE 6+ issue.

 

Apparently server side gets the following info from input type="image':

 

control_name => value

control_name_x => x co-ord

control_name_y => y co-ord

 

i've been told to test for existence of x or y by doing the following:

 

<?php
if (isset($_POST["control_name_x"]))
{
// form submitted 
}
?>

 

i'm not very certain of what it is I'm supposed to be doing here.

http://www.aaronreynolds.co.uk/using-an-image-submit-button-in-php/

The HTML specification only requires that x,y coordinates where the image is clicked to be sent to the server. Some browsers only supply that information while other browsers supply the value="..." as well. To make your code work for all browsers, only expect the x,y coordinates - http://us.php.net/manual/en/faq.html.php#faq.html.form-image or use a hidden field with a specific name/value that your code will use to detect that the form has been submitted.

 

The problem is not an IE problem. IE and a couple other major browsers follow the specification. Browsers that send the value="..." are doing their own thing outside the specification.

I really don't know what you mean by

 

expect the x,y coordinates

 

or

 

use a hidden field with a specific name/value that your code will use to detect that the form has been submitted.

 

The theory makes sense but I don't know where to start in terms of implementation. Am I editing the name of the image or how I call it in the isset condition?

If you receive two values that both indicate the image was clicked, why would you need to check more than one of them? You would only use both if you were actually checking the coordinate values where the image was clicked.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.