我对带有选择选项的粘性表单有疑问。这是我的书所说的代码:
<?php
if(isset($_POST['submit']))
{
echo ' thanks! ';
$submit = $_POST['year'];
}
?>
<form action="" method="post">
<?php
$y = range(1920, 1950);
echo '<select name="year">';
for ($y = 2008; $y <= 2018; $y++) {
echo "<option value=\"$y\";
if ($year == $y) {
echo ' selected="selected"';
}
echo ">$y</option>\n";
}
echo '</select>';
?>
<input type="submit" name="submit" value="SUbmit"/>
</form>