My colleague was getting frustrated earlier when trying to replicate the effects of a form from one website into a different website.  She was using a HTML input tag set to type=image, as follows:

<input type="image" src="images/image-name.gif" alt="Send Message" value="Submit" />

Now I don't get involved in HTML that much anymore so I was curious when she said that although the form was posting back when she clicked on the image, the server-side PHP script wasn't recognising the postback.  In fact, the page was just re-rendering.  My colleague has used this same simple HTML on numerous occassions before including a GET-based PHP form to another page.

After a trawl around Google we found suggestions from the HTML definition that you should specify the HTML action in the "value" attribute.  This we did as above to no avail.

Now since I am always suspicious of PHP (amongst other technologies) for handling things just that little bit different I looked for any PHP-related posts on the subject.

 Turns out this is actually because IE (from version 6 onwards at least) doesn't send the value for a HTML input of type=image.  Not like Microsoft to adopt just part of a standard I hear you say with you tongue in your cheek.

Now since the type=image is supposed to return x & y co-ordinates from the browser there is a simple work around.

The server-side code would normally receive the following data from a HTML input tag where type=image:

control_name => value
control_name_x => x co-ord
control_name_y => y co-ord

Since with IE you don't get the value returned you can simply test for the existence of x or y as follows:

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

So there we go, PHP not to blame after all.  What was I thinking?

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Related posts

Comments

apache.morelyrics.co.uk

Tuesday, July 08, 2008 2:29 AM

pingback

Pingback from apache.morelyrics.co.uk

» Using an image submit button in PHP Apache: What The World Is Saying About Apache

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

Monday, October 13, 2008 8:39 PM

AaronReynolds.co.uk

Aaron Reynolds - for C# and VB .NET, HTML, PHP, CSS, ASP, DNS and BIND, Windows Server 2003 etc...