lakay
lakay

Reputation: 5

dropdown list value will not echo

very simple code, but the dropdown value for $race will not echo. $name echos fine. what am i missing? Thank you in advance.

<?php
if (isset($_POST['peeps'])) {
    $race = $_POST['race'];
    $name = $_POST['name'];

    echo $race;
    echo "<br>";
    echo $name;     
}
?>

<form action="x_test.php" method="post">
<select name="race">
    <option value="">alien</option> //will not echo if selected
    <option value="">earthling</option>
</select>

<input type="text" name="name" value="" id="name" />  //echos fine when filled out

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

Upvotes: 0

Views: 872

Answers (1)

Ken Herbert
Ken Herbert

Reputation: 5236

Because your options don't have a value to pass.

Try this:

<option value="alien">alien</option>
<option value="earthling">earthling</option>

Upvotes: 1

Related Questions