marmite Posted April 24, 2007 Share Posted April 24, 2007 So, the form doesn't realise it's been submitted when I use an image... any ideas why? According to my Googling, you just use "image" instead of "submit" as type... _____________________________________________________________________________________________________ IMAGE INSTEAD OF BUTTON - DOESN'T POST FORM CODE <form action="/cart.php" method="post" id="mycart"> <td><input name="qty" type="text" id="qty" size="3" /></td> <td><input type="image" src="/images/cart.gif" id="submit5" name="submit5"></td> </form> PHP CODE - always generates 222 after submitting form (i.e. form not POSTed) if ($_POST['submit5']) { $_SESSION['test']="abc"; } else { $_SESSION['test']="222"; } _____________________________________________________________________________________________ NORMAL SUBMIT BUTTON - DOES POST FORM CODE <form action="/cart.php" method="post" id="mycart"> <td id="normal"><input name="qty" type="text" id="qty" size="3" /></td> <td id="normal"><input type="image" src="/images/cart.gif" id="submit5" name="submit5"></td> </form> PHP CODE - always generates abc to say form has been POSTed if ($_POST['submit5']) { $_SESSION['test']="abc"; } else { $_SESSION['test']="222"; } __________________________________________________________________________________________________ Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 24, 2007 Share Posted April 24, 2007 avoid it! safari and camino don't render the image inputs - instead they put a mac glass button there with no text on it. FF and IE are different in how they send information on the submision of the image input - so you have to code for both - very dull. Stick to using submit buttons and STYLE them (note same browsers don't style buttons very well BUT you can do something about that) Quote Link to comment Share on other sites More sharing options...
marmite Posted April 24, 2007 Author Share Posted April 24, 2007 Thanks for the advice Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 24, 2007 Share Posted April 24, 2007 why dont you try some CSS and just change the background of the button? (if that's possible. worth a try tho) Quote Link to comment Share on other sites More sharing options...
marmite Posted April 24, 2007 Author Share Posted April 24, 2007 Cos I'm not having much luck with them, either! http://www.phpfreaks.com/forums/index.php/topic,137378.0.html Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 24, 2007 Share Posted April 24, 2007 i ment more like this: #button { background: url(image); } <input type="submit" id="button" value="Submit"> Quote Link to comment Share on other sites More sharing options...
AndyB Posted April 24, 2007 Share Posted April 24, 2007 Just for the record - again - when you use an image as a submit, the html standard is to pass the x and y coordinate values of where you clicked relative to the upper left corner of the image. Why? Because that's how image maps work. php allows you to retrieve those x and y values. For example, if the NAME of your submit field is 'submit', then $_POST['submit_x'] and $_POST['submit_y'] will contain the values and $_POST['submit'] doesn't exist. So, for the original poster, try checking for $_POST['submit5_x'] instead and you'll be fine. Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 24, 2007 Share Posted April 24, 2007 oh.. nice...thanks for the lesson AndyB =) Quote Link to comment Share on other sites More sharing options...
marmite Posted April 25, 2007 Author Share Posted April 25, 2007 Thanks for this Andy. I had given up hope. This works great! Quote Link to comment Share on other sites More sharing options...
taith Posted April 25, 2007 Share Posted April 25, 2007 <a href="javascript:document.formname.submit();"><img src=""></a> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.