monkeymade Posted February 27, 2008 Share Posted February 27, 2008 ok, I'm sure this is something simple I'm doing wrong, it always is lol. I'm making a form, instead of a normal submit button, I am using an image. The code for the submit button is this: <input type="image" src="images/savedata.jpg" border="0" name="submit" value="test"> Then, I try and retrieve the value of it. I have more than one form on the page, and I do it this way so I know which form was filled out: <?PHP $submit = $_REQUEST['submit']; echo "the value of submit is $submit"; ?> This should echo out the word "test" since thats the value I assigned to the button (or so I'd hoped), but instead it comes out blank. I've also tried $submit = $_POST['submit']; Thinking that maybe request just wasn't working in this instance, but still with no luck. Anyone know what I am doing wrong here? Or if this can even be done? Thanks for your help! Quote Link to comment Share on other sites More sharing options...
bpops Posted February 27, 2008 Share Posted February 27, 2008 I've personally never used an image for a submit button, so can't help you there, but you could always use a hidden variable to accomplish this easily: <input type="hidden" name="hiddenSubmit" value="test"> Quote Link to comment Share on other sites More sharing options...
revraz Posted February 27, 2008 Share Posted February 27, 2008 The input type should be "submit". Maybe change the graphic with CSS. Quote Link to comment Share on other sites More sharing options...
bpops Posted February 27, 2008 Share Posted February 27, 2008 But the type="image" should work for submitting form, it's just the value he's having trouble getting. Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 27, 2008 Share Posted February 27, 2008 let see the whole form then... Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 27, 2008 Share Posted February 27, 2008 try this please.. <INPUT TYPE="image" SRC="images/savedata.jpg" HEIGHT="30" WIDTH="173" BORDER="0" ALT="Submit Form"> Quote Link to comment Share on other sites More sharing options...
monkeymade Posted February 27, 2008 Author Share Posted February 27, 2008 nope RedArrow, that didn't do it either, just scrunched up my image lol. I don't know if it will help at all, but this is the page I am using it on: http://admin.dadnladlawnservice.com/customermaint.php There are 5 images at the bottom, each will be a "submit button" and each will do different things, this is why I am not using a hidden field, because its basically just 1 form, with 5 different submit buttons. A hidden field would get entered with all 5, and not tell me which one was pushed. I haven't added the security part yet, so its open to anyone to look at it, if you can help with this that would be great! Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 27, 2008 Share Posted February 27, 2008 you can not name the image submit button example and try! working example with image as submit button <?php $name=$_POST['name']; if($name){ echo $name; } ?> <form method="POST" action=" "> <br> <br> your name please <br><br> <input type="text" name="name"> <br><br> <INPUT TYPE="image" SRC="http://z.about.com/d/paranormal/1/0/4/S/myrtle_ghost.jpg" HEIGHT="10%" WIDTH="10%" BORDER="0" ALT="Submit Form"> </form> Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 27, 2008 Share Posted February 27, 2008 your have to use the isset around a form condition......... <?php $name=$_POST['name']; if(isset($name)){ echo $name; } ?> Quote Link to comment Share on other sites More sharing options...
monkeymade Posted February 27, 2008 Author Share Posted February 27, 2008 ahh the isset, that might work for what I want to do. Thanks guys Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 27, 2008 Share Posted February 27, 2008 Actually, <?php if(isset($_POST['name'])){ $name=$_POST['name']; echo $name; } ?> is more correct and will not trigger a warning. 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.