2013-10-08 35 views
0

我有一個帶有下拉列表的表單。除了下拉式選擇,我會收到一封電子郵件,其中包含返回值這是空白的,而不是顯示選擇的內容。 這裏是我的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"; 

謝謝

+0

還有你的PHP代碼是顯示下拉列表框。問題可能出現在您檢索表單值和發送電子郵件的代碼中。你能展示那部分代碼嗎? – Uours

回答

1

你的HTML被打破:

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

我對html進行了更改,但這並未糾正我的問題。當php發送表單電子郵件時,我得到這個...下面引用表單詳細信息 姓名:姓名進入 EMAIL:[email protected] 電話:909-555-1234 PAWN:沒有 買入:是的 項目類型: 關於我的項目:14克拉黃金手鐲5克.....項目類型爲空白不顯示標記的內容。 –

+0

你需要學習基本的調試。你的表單有一個名爲'items'(複數)的字段,並且在你的PHP中,你正試圖訪問'item'(單數)。 –

+0

我已經改變了我的原始php中的項目,只是複製了錯誤的一個。單數版本現在在這裏使用和PHP仍然無法正常工作。 –