I3erk Posted April 26, 2011 Share Posted April 26, 2011 I an quite new to web programming and i and trying to make a ComboBox for my website. This ComboBox will be on a promo page for the website. Right now, i created the ComboBox and it works perfectly. The next thing i want to do are 2 things (and have them done simultaneously): 1. when the submit button is clicked, i want it to save whatever is selected in the ComboBox into a database/spreadsheet, in order to determine the number of times the option is selected. 2. when the submit button is clicked, the client will then get sent to the website homepage. Can anyone point me in the right direction as to how i can go about doing this? Thanks. I3erk <form id="form1" name="form1" method="post" action="http://www.maisonsbellevue.com"> <select name="frmhowhear" id="frmhowhear"> <option value="">Select one…</option> <option value="Courrier Laval">Courrier Laval</option> <option value="L'Étoile">L'Étoile</option> <option value="Le Progress">Le Progress</option> <option value="Le Richelieu">Le Richelieu</option> <option value="Le Mirabel">Le Mirabel</option> <option value="L'Information du Nord">L'Information du Nord</option> <option value="Le Regional">Le Regional</option> <option value="The Gazette">The Gazette</option> <option value="Tremblant Express">Tremblant Express</option> <option value="La Flèche">La Flèche</option> <option value="Brochure">Brochure</option> <option value="Recommendation">Recommendation</option> </select> <input type="submit" value="Continue to Maisons Bellevue"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/234788-how-to-store-selected-data-from-a-combobox/ Share on other sites More sharing options...
matthewgregory Posted April 29, 2011 Share Posted April 29, 2011 ok so first of all you will need to set the action attribute of the form a php file. For example <form id="form1" name="form1" method="post" action="processForm.php"> This file (processForm.php) would need to be in the same directory ('folder' if your a windows fanboy) as the file that contains the form. Then in this php file you would need to fetch the selected options from the combobox which will be in the following variable $_POST['form1']['frmhowhear']; and will be an array. You can then insert this into your database. Once done you can redirect the user back to the home page by doing this: header('Location: http://www.maisonsbellevue.com'); That should get you pointed in the right direction Quote Link to comment https://forums.phpfreaks.com/topic/234788-how-to-store-selected-data-from-a-combobox/#findComment-1208069 Share on other sites More sharing options...
wildteen88 Posted April 29, 2011 Share Posted April 29, 2011 Then in this php file you would need to fetch the selected options from the combobox which will be in the following variable $_POST['form1']['frmhowhear']; The form name is not sent in the $_POST array. The correct variable will be $_POST['frmhowhear'] to grab the selected value. Quote Link to comment https://forums.phpfreaks.com/topic/234788-how-to-store-selected-data-from-a-combobox/#findComment-1208070 Share on other sites More sharing options...
matthewgregory Posted April 29, 2011 Share Posted April 29, 2011 my bad Quote Link to comment https://forums.phpfreaks.com/topic/234788-how-to-store-selected-data-from-a-combobox/#findComment-1208076 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.