harkly Posted February 19, 2010 Share Posted February 19, 2010 Trying to get my form to submit to itself. However I am also trying to use an image for my submit button, when I set the type='image' it will not submit to itself. Can someone help me figure out why? my button code: <input type='submit' name='submit' value='submit' src='img/button_add.gif' width='64' height='25' class='outline' onmouseover=\"javascript:this.src='img/button_add2.gif';\" onmouseout=\"javascript:this.src='img/button_add.gif';\"> my if: if( isset($_POST['submit'])) form: <form method='post' action="<?php echo $_SERVER["PHP_SELF"]; ?>" name='mailcheck' id='form_id'> Everything works well if I don't post to self so I can always do that. Quote Link to comment https://forums.phpfreaks.com/topic/192580-post-to-self/ Share on other sites More sharing options...
trq Posted February 19, 2010 Share Posted February 19, 2010 <form method='post' action="" name='mailcheck' id='form_id'> Quote Link to comment https://forums.phpfreaks.com/topic/192580-post-to-self/#findComment-1014617 Share on other sites More sharing options...
harkly Posted February 19, 2010 Author Share Posted February 19, 2010 That doesn't work either. Works fine when type='submit' but not when type='image' Quote Link to comment https://forums.phpfreaks.com/topic/192580-post-to-self/#findComment-1014856 Share on other sites More sharing options...
sader Posted February 19, 2010 Share Posted February 19, 2010 Not sure 100% but it may be that in this case on javascript can help <form name='myFormName' method='post'> <input type='image' onclick='document.myFormName.submit()'> </form> Quote Link to comment https://forums.phpfreaks.com/topic/192580-post-to-self/#findComment-1014858 Share on other sites More sharing options...
taquitosensei Posted February 19, 2010 Share Posted February 19, 2010 when you use type='submit' it posts the x,y coordinates of the images. The name plus x or y. Try a print_r($_POST) at the top of the page with type='submit' and you'll see what I'm talking about. You should check for one of those instead. Or use a hidden field and check for it. <input type='hidden' name='submitmyform' value='true'> for the x, y if(isset($_POST['submitmyform_x'])); // or submitmyform_y { // do whatever here } for the hidden field if($_POST['submitmyform']) { // do whatever here } Quote Link to comment https://forums.phpfreaks.com/topic/192580-post-to-self/#findComment-1014880 Share on other sites More sharing options...
harkly Posted February 19, 2010 Author Share Posted February 19, 2010 Thanks everyone! taquitosensei's fix worked! I had no idea that it was posting my image coodinates : ( Quote Link to comment https://forums.phpfreaks.com/topic/192580-post-to-self/#findComment-1014913 Share on other sites More sharing options...
taquitosensei Posted February 19, 2010 Share Posted February 19, 2010 It took a bit of hitting my head against the wall to figure that one out. Quote Link to comment https://forums.phpfreaks.com/topic/192580-post-to-self/#findComment-1014918 Share on other sites More sharing options...
harkly Posted February 19, 2010 Author Share Posted February 19, 2010 LOL I really appreciate it!! Quote Link to comment https://forums.phpfreaks.com/topic/192580-post-to-self/#findComment-1014930 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.