1

I am using a piece of code within a form for a drop down list that is populated by a directory on a web site:

  <select name="mydrop" id="mydrop">
  <option value="" selected="selected">--a--</option>
    <?php 
            foreach(glob(dirname(__FILE__) . '/images/*') as $filename){
            $filename = basename($filename);
            echo "<option value='" . $filename . "'>".$filename."</option>";
        }
?>

</select>

I have two text boxes and a text area inputting. When I action my php file all of the data values are there but not from this drop down menu. Any ideas why?

I use:

$first=$_POST['first'];
$last=$_POST['last'];
$email=$_POST['email'];
$table=$_POST['table'];
$image=$_GET['mydrop']; //Doesn't work
4

2 回答 2

2

那么你为什么要使用$_POST其他所有东西,而$_GET不是<select>? 如果表单是通过 POST 提交的,mydrop也应该在$_POST.

这一行:

$image=$_GET['mydrop']; //Doesn't work

应该是这样的:

$image = $_POST['mydrop'];
于 2013-04-23T21:52:04.200 回答
1

确保value每个属性都<option>需要填写。这就是POST表单的内容。

您正在使用$image=$_GET['mydrop'];,但应该是$image=$_POST['mydrop'];$_GET用于 URL 参数,例如?foo=bar在 URL 的末尾。$_GET['foo']将是bar

于 2013-04-23T21:49:24.670 回答