下拉菜单不返回电子邮件表单中的值

时间:2013-10-08 18:49:53

标签: php forms

我有一个带有下拉列表的表单。我收到的电子邮件返回的值除了下拉选项外。这是空白而不是显示所选内容。 这是我的HTML

Item Type<span style="color: #FF0000">*</span>
<select name="items" class="items" id="items">
   <option value="0">Please Select</option>
   <option value="1">Gold</option>
   <option value="2">Silver</option>
   <option value="3">Watch</option>
   <option value="4">Electronics</option>
   <option value="5">Tools</option>
   <option value="6">Lawn Equipment</option>
   <option value="7">Guns</option>
   <option value="8">Musical Instrument</option>
   <option value="9">Car</option>
   <option value="10">Recreational Vehicle</option>
   <option value="11">Collectible</option>
   <option value="12">Other</option>
 </select>

这是我的php

    $name = $_POST['name']; // required
    $email_from = $_POST['email']; // required
    $phone = $_POST['phone']; // required
    $comments = $_POST['comments']; // required
$servicetype = array("pawn" => false, "buy" => false);  //checkboxes
$items= $_POST['items'];

     $items= array (1=>'Gold', 'Silver', 'Watch', 'Electronics',  //item array
'Tools', 'Lawn Equipment', 'Guns', 'Musical Instruments',
'Car', 'Recreational Vehicle', 'Collectible', 'Other');
{   echo'<select name="items">'; 

     // For each value of the array assign variable name "item" 
         foreach ( $items as $key => $value ) { 
            echo"<option value=\"$key\">$value</option>\n";
         }
         echo'</select>';     
     }
//EMAIL MESSAGE DETAILS     
$email_message .= "Name: ".clean_string($name). "\r\n";
$email_message .= "Email: ".clean_string($email_from). "\r\n";
$email_message .= "Phone: ".clean_string($phone). "\r\n";
$email_message .= "Pawn: " . clean_string(($servicetype["pawn"]) ? "Yes" : "No"). "\r\n";
$email_message .= "Buy: " . clean_string(($servicetype["buy"]) ? "Yes" : "No") . "\r\n";
$email_message .= "Item Type: ".clean_string($items). "\r\n";
$email_message .= "About My Item: ".clean_string($comments). "\r\n";

谢谢

1 个答案:

答案 0 :(得分:1)

你的HTML坏了:

<select name="items" class="items" id="items" ;">
                                              ^^----