jeffjohnvol Posted December 28, 2007 Share Posted December 28, 2007 Can anyone advise how I can have a form, with 2 submit buttons that pass a different parameter that I can use? In otherwords, I want one button that I can act on a "preview" and one that can act on a "upload". I don't know how to tell in my "post" logic which button was hit. Each function requires all of the "post" values (inputs) of the form. I could use two fake buttons as images and a url, but I would have to have all the parms on the url link, wouldn't I? Thanks in advance. Jeff Quote Link to comment https://forums.phpfreaks.com/topic/83480-solved-submitting-with-2-buttons-while-using-all-inputs-on-form/ Share on other sites More sharing options...
papaface Posted December 28, 2007 Share Posted December 28, 2007 Just name your buttons differently and process them accordingly: <input type="submit" name="preview" value="preview" /> then if ($_POST['preview']) { // do something for preview } Quote Link to comment https://forums.phpfreaks.com/topic/83480-solved-submitting-with-2-buttons-while-using-all-inputs-on-form/#findComment-424703 Share on other sites More sharing options...
revraz Posted December 28, 2007 Share Posted December 28, 2007 <?php if ($_POST['submit1']) { echo "You hit Submit 1"; } if ($_POST['submit2']) { echo "You hit Submit 2"; } ?> <form method="POST"> <input type='submit' name="submit1" value="Submit 1"> <input type='submit' name="submit2" value="Submit 2"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/83480-solved-submitting-with-2-buttons-while-using-all-inputs-on-form/#findComment-424706 Share on other sites More sharing options...
p2grace Posted December 28, 2007 Share Posted December 28, 2007 If you wanted to get a little more fancy you could use ajax too. I'd recommend xajax http://xajaxproject.org/. Quote Link to comment https://forums.phpfreaks.com/topic/83480-solved-submitting-with-2-buttons-while-using-all-inputs-on-form/#findComment-424708 Share on other sites More sharing options...
jeffjohnvol Posted December 28, 2007 Author Share Posted December 28, 2007 Thanks all. I knew it must have been simple. :-) Quote Link to comment https://forums.phpfreaks.com/topic/83480-solved-submitting-with-2-buttons-while-using-all-inputs-on-form/#findComment-424709 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.