January 24, 201214 yr I was wondering if someone could give me some help... My form is below - basically it has 2 drop down menus and a search button. The first drop down is 'Interests' and offers a range of options. The second is 'Experience' and offers a range of years experience. So what the user will do is choose a interest and then choose the amount of years experience they have - depending on the choices they will be forwarded to a relevant page. I normally work this stuff out myself through Google but i don't even know what you call this type of web form work! Any pointers would be a massive help. <form id="devroutes" name="devroutes" method="post" action="php??"> <p class="pinkpara"> Interests : <select name="xlevl" id="xlevl"> <option>(please select)</option> <option>HR</option> <option>Management</option> <option>In-house training</option> <option>Not sure</option> <option>Something else etc</option> </select> </p> <p class="pinkpara">Exeprience : <select name="xlevl" id="xlevl"> <option>(in years)</option> <option>1 - 2</option> <option>3 - 5</option> <option>5 - 7</option> <option>8 +</option> </select> </p> <p><input name="srch" type="button" value="Search" /></p> </form>
January 25, 201214 yr In your form action redirect the submitted form data to the page where you are going to run the PHP that selects and displays information from the database based on the submitted options, for example <form id="devroutes" name="devroutes" method="post" action="resultspage.php"> Then for all of your menu options you need to set a value and it is this value that will be used to select the correct data from the database so it will depend on how you sotre it, but if sotred by the same values as those displayed in the option text, it would be something like this: <option value="HR">HR</option> . . <option value="2">1 - 2</option> This is just an example of how you need to do it and you will have to format as needed.
January 31, 201214 yr Author Thanks simplypixie. I've made the changes and understand the process needed, any ideas how i would go about coding the php? Obviously first connect to db - then would you use a chain of if statments or would that bog the code down a bit? Do you know anywhere in the forums with any initial scripting to use? Thanks James
January 31, 201214 yr Hi, If you're going to be forwarding users to different areas, the combination of an if statement and a header redirect would work, like: if($number >= "5"){ header('Location: http://www.yourdomain.com/page1'); } Just an example obviously but a combination of these techniques will achieve what you wish. Remember, if using the header statement you must not render any HTML before this in your php "processor" file, resultspage.php. Furthermore, if you're having a lot of redirects or potential "if" statements, consider using the switch function instead. See these links for more info: http://php.net/manual/en/function.header.php http://php.net/manual/en/control-structures.if.php http://php.net/manual/en/control-structures.switch.php Cheers
Create an account or sign in to comment