2
Contributors
1
Reply
12
Views
3 Years
Discussion Span
Last Post by cereal
0

Assign a name attribute to the select tag, a value attribute to each option tag, set the method to the submitting form and then read the matching array, for example, if you set the POST method, then you will have to read $_POST, here's an example:

<form method="post" action="destination.php">
    <select name="color">
        <option value="red">Red</option>
        <option value="green">Green</option>
        <option value="blue">Blue</option>
    </select>

    <input type="submit" name="submit" value="submit" />
</form>

Now the receiving script (destination.php) can do:

<?php

    if($_POST)
    {
        # check if $_POST['color'] is available
        if(array_key_exists('color', $_POST))
        {
            # execute insert query here
            echo $_POST['color'];
        }
    }
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.