ecopetition Posted August 13, 2009 Share Posted August 13, 2009 Hi guys. I made a drop down list similar to: <form action="action.php" method="post"> <select name="mode"> <option value="option1">Option 1</option> <option value="option2">Option 2</option> <option value="option3">Option 2</option> <input type="submit" name="submit" value="Submit" /> </select> </form> What PHP should be contained in the form action to return the option value when that option is selected? I know this is probably very simple but I have searched Google and found nothing on it. Thanks a lot, Ecopetition Quote Link to comment https://forums.phpfreaks.com/topic/170011-mode-from-drop-down-list/ Share on other sites More sharing options...
ohdang888 Posted August 13, 2009 Share Posted August 13, 2009 what do you mean??? are you asking how to retireve the value of that field?? if so...its value will be stored in this var: $_POST['mode']; Quote Link to comment https://forums.phpfreaks.com/topic/170011-mode-from-drop-down-list/#findComment-896882 Share on other sites More sharing options...
HoTDaWg Posted August 13, 2009 Share Posted August 13, 2009 bro, your form action is action.php yet your method is equal to post... if your gonna be using the $_POST method of retrieving data than your form's action should be $_SERVER['PHP_SELF'] otherwise if you are using the get method than the form should be set to: <form name="formname" action="action.php" method="get"> if it is the get method ur gonna be using: the action.php should like <?php //action .php $mode = $_GET['mode']; echo $mode; ?> HoTDaWg Quote Link to comment https://forums.phpfreaks.com/topic/170011-mode-from-drop-down-list/#findComment-896889 Share on other sites More sharing options...
ohdang888 Posted August 13, 2009 Share Posted August 13, 2009 if your gonna be using the $_POST method of retrieving data than your form's action should be $_SERVER['PHP_SELF'] otherwise if you are using the get method than the form should be set to: <form name="formname" action="action.php" method="get"> that completely wrong. the action attribute of the form does NOT have to be set to current page for it to be POST... in fact, i'd recommend using POST for 99.9% of the forms you create Quote Link to comment https://forums.phpfreaks.com/topic/170011-mode-from-drop-down-list/#findComment-897610 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.