Forum Moderators: coopster

Message Too Old, No Replies

Form processing problem with input type=image!

Sadly, the fix didn't work for me...

         

frank999

8:14 am on Jan 21, 2005 (gmt 0)

10+ Year Member



Hi guys,

In this message some time ago [webmasterworld.com] some of you were discussing Form processing problem with input type=image.

I myself have just had exactly the same problem. I tried the fix mentioned in the post:

With image submits, you'll get 2 name/value pairs when the button is clicked. For 'restore', the browser will send 'restore.x' and 'restore.y', and the values are the x/y coordinates of where they clicked on the image.
Try

if (isset($_POST['restore'] ¦¦ isset($_POST['restore_x']))
{
code..
}

..and you'll be fine.

Note that PHP will turn the '.x' suffix into a '_x'...

Ufortunately however hard I tried it simply would not return the value, instead returning a parse error (or of course a syntax error) whichever way I edited the statement or wherever I placed it. It's not like it's a rocket science line of code but I really have no idea why it wouldn't work.

Anyway, not having the time or the energy to continue to battle with this which was holding up my work, but nevertheless still wanting to have an image submit button I simply did it with CSS. The button is still a submit form button (with no 'value') and the style sheet defines its size, borders and background image.

This fix got me out of a hole and is browser-independent (tested and works in Lynx). So, much as I would like to use image submit buttons in my php-based forms, I think from now on I will do it the 'easy' way :)

Cheers for now

Frank

coopster

4:15 pm on Jan 21, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, frank999.

Yeah, there seems to be a typo in that post, a missing parenthesis. It should work for you once you fix the parse error:

if (isset($_POST['restore']) ¦¦ isset($_POST['restore_x'])) 
{
code..
}
Don't forget that the forum breaks the pipe symbol (¦) so you will need to rekey it after cutting and pasting any code from this web site.