IT-Guy Posted March 1, 2008 Share Posted March 1, 2008 Hey I clicked a couple of links online and I haven't been able to find any information regarding this: Does anyone know a good tutorial for this: I have a drop down menu, I want users to be able to select an option from the menu > then hit 'submit' and get a php script to look at which ever option was chosen and if it was option 1, it goes to one URL, if it was option 2 it goes to a different URL and so on. I know its quite simple so if anyone knew a script that would be benifical, but if anyone knew of a good tutorial that would be great to Quote Link to comment https://forums.phpfreaks.com/topic/93792-drop-down-menu/ Share on other sites More sharing options...
Mario F. Posted March 1, 2008 Share Posted March 1, 2008 If I understood your requirements right, you don't use PHP for this. You use straight (X)HTML/CSS. Quote Link to comment https://forums.phpfreaks.com/topic/93792-drop-down-menu/#findComment-480588 Share on other sites More sharing options...
IT-Guy Posted March 1, 2008 Author Share Posted March 1, 2008 Well here is my script so far: <form action="handle.php" method="post"> <select name=url> <option value="http://php.about.com">Try</option> <option value="http://www.identity.st">Identity</option> </select> <input type="submit" value="Go"> </form> Here is handle.php <?php header( 'Location: http://about.php.com' ) ; ?> Now when the form submits it does go to that URL above, but as you can see I have two options in the drop-down, how do I add another URL for the second option Do I just need to add another header( 'Location: http://what-ever.com' ); ? Quote Link to comment https://forums.phpfreaks.com/topic/93792-drop-down-menu/#findComment-480597 Share on other sites More sharing options...
trq Posted March 1, 2008 Share Posted March 1, 2008 <?php header('Location: '. $_POST['url']) ; ?> Quote Link to comment https://forums.phpfreaks.com/topic/93792-drop-down-menu/#findComment-480599 Share on other sites More sharing options...
Mario F. Posted March 1, 2008 Share Posted March 1, 2008 That is fine, but you do realize that you could, and probably should, be doing this without a form or PHP. Unless you don't have to worry about search engine bots or accessibility, it is best to use server-side scripting for only when it's needed. Not just because you can. Your current menu will defeat search engine bots and will confuse people with disabilities that need to use screen reading aiding software. Quote Link to comment https://forums.phpfreaks.com/topic/93792-drop-down-menu/#findComment-480617 Share on other sites More sharing options...
IT-Guy Posted March 1, 2008 Author Share Posted March 1, 2008 I dont follow what you are saying. All Im doing really: Is making a drop down menu. In the drop down menu is a list of airports. Really all the user has to do is select the airport (There is only a list of five) the user just has to select which airport, hit 'Submit' and a Staff List from that particular airport is then displayed on our website. But continue with what you are saying, because if you know of a better way let me know I would like to avoid using PHP if I could, but if I absolutely have too, then its no big deal. Quote Link to comment https://forums.phpfreaks.com/topic/93792-drop-down-menu/#findComment-480623 Share on other sites More sharing options...
Mario F. Posted March 1, 2008 Share Posted March 1, 2008 Well, not saying this for you to avoid using PHP Just mentioning the fact you are probably looking at server-side scripting the wrong way. I can understand your confusion though if you are learning website design as you are learning PHP. I think this the the case since you called script to a snippet of HTML. I suggest perhaps you do it the other way around. Learn website design before learning PHP. It isn't difficult really and in two or 3 weeks you will be here again, this time with a better baggage. I personally think server-side scripting is much more fun (and profitable) when we feel comfortable around HTML and CSS. Your menu doesn't need PHP. In fact it will suffer from its use. You can do it with HTML and CSS. This way you will be separating content and presentation from scripting. Now imagine, after having done of those, you decide that the links to the pages opened by that menu will be stored in a database. It's at that time you will want PHP. It's when you want to create dynamic content. I really believe that to better understand these differences you should start by HTML, followed by CSS, followed by PHP Quote Link to comment https://forums.phpfreaks.com/topic/93792-drop-down-menu/#findComment-480647 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.