PHP dropdown menu

Posted on 2007-10-19
Last Modified: 2013-12-13
I'm looking for a PHP dropdown menu that changes pages when an option is selected, such as the Ford option changes to the Mustang page. Is the PHP code better than using Java ? I"m looking for security in he code also. I will be reading the values from a MySQL database which is already setup.

Question by:mhoggatt1
    LVL 13

    Accepted Solution

    Ok, try this: (Place the php code at the very top of your script, even before an empty line or an html type declaration)

              header('Location: '.$_POST['page']);

    Somewhere in your body write:

    <form action='' method='post'>
    <select name='page' onchange='this.form.submit()'>
    <option>Select a make:</option>
    <option value='Ford/mustang.html' onclick='this.form.submit()'>Ford Mustang</option>
    <option value='Ford/F150.html onclick='this.form.submit()''>Ford F-150</option>
    <option value='Dodge/viper.html onclick='this.form.submit()'>Dodge Viper</option>
    ...(add as many additional options as you like)

    Author Comment

    Thanks for the reply. Let me see if I can integrate it with my DB and I'll get back to you tomorrow.


    Author Comment

    Here is my code with the database added. How do I make the options equal to the values in my DB ?
    I wan't action_name to appear in the menu which changes to the page when selected.
    I am not actually using cars for my code but for purposes of this question action_name would be Ford and directory_link would be Mustang.

    LVL 13

    Expert Comment

    Please post your code and I will take a look at it.

    Author Comment

    Thanks for all your help.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now