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" ;">
                                                  ^^----
    
    评论

报告相同问题?

悬赏问题

  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染