paschim Posted January 18, 2008 Share Posted January 18, 2008 Ok i am just beginning in php/html/...., so please be descriptive in your replies. I was trying to create a simple one page form where there will be 3 to 4 buttons (along with other fields), and clicking on any one of those buttons would submit the form. Then i want to return exactly which button was pressed and show it in a message. i cant figure out how to do this part. if the button types were all "submit" then clicking any one of them will submit the form, but then how do i check which one was pressed exactly?if i am on the wrong path, then please show me the right way! Quote Link to comment https://forums.phpfreaks.com/topic/86633-solved-totally-noob-need-help/ Share on other sites More sharing options...
papaface Posted January 18, 2008 Share Posted January 18, 2008 <?php if ($_POST) { if ($_POST['button1']) { echo "You clicked button 1"; } if ($_POST['button2']) { echo "You clicked button 2"; } if ($_POST['button3']) { echo "You clicked button 3"; } } else {?> <form name="" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type="submit" name="button1" value="Button 1"> <br /> <input type="submit" name="button2" value="Button 2"> <br /> <input type="submit" name="button3" value="Button 3"> </form> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/86633-solved-totally-noob-need-help/#findComment-442688 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.