dongyuli4538 2013-10-08 18:49
浏览 46

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

I have a form with a drop down list. I receive email with a values returned except for drop down selection. It's blank instead of showing what was selected. Here is my 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>

and here is my 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>
";
         }
         echo'</select>';     
     }
//EMAIL MESSAGE DETAILS     
$email_message .= "Name: ".clean_string($name). "
";
$email_message .= "Email: ".clean_string($email_from). "
";
$email_message .= "Phone: ".clean_string($phone). "
";
$email_message .= "Pawn: " . clean_string(($servicetype["pawn"]) ? "Yes" : "No"). "
";
$email_message .= "Buy: " . clean_string(($servicetype["buy"]) ? "Yes" : "No") . "
";
$email_message .= "Item Type: ".clean_string($items). "
";
$email_message .= "About My Item: ".clean_string($comments). "
";

Thank you

  • 写回答

1条回答 默认 最新

  • douqi3913 2013-10-08 18:52
    关注

    Your html is broken:

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

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮