user2398101
user2398101

Reputation: 339

using selected value from dropdown list

I have a HTML form with dropdown list populated by php. I want the user to be able to select an option from the dropdown list and click on "Proceed" button which would open a new page based on the selected value.

<form name="selectPatient" method="post">
            <div align="centre">
            <select name="patient_dropdown">
            <?php
            include "connection.php";

            $sql = mysql_query("SELECT Name from patient_info");
            while ($row = mysql_fetch_array($sql))  {
            echo "<option value=".$row['Name'].">".$row['Name']."</option>";
            }
            ?>
            </select>
            </div>
            <br>
            <br>
        <input type="submit" name="submit" value="Proceed"/>
    </form>
        <?php
        if(isset($_POST['submit'])) {
    header("Location: http://localhost/lei/test.com/proper/specific_patient.php");
        }
        ?>

The code above works fine. How do I get the selected value from dropdown list?? I want to use the selected value to run a SQL query using php to get other details of the patient and then call a javascript file with that information. How can I do that??

Thanks in advance !

Upvotes: 0

Views: 158

Answers (1)

MonkeyVoodoo
MonkeyVoodoo

Reputation: 538

You need to check your $_POST variables on submit:

  $patient_dropdown = isset($_POST['patient_dropdown']) ? $_POST['patient_dropdown'] : false;

Upvotes: 0

Related Questions