Isabel Polanco
Isabel Polanco

Reputation: 11

drop down menu not returning values in email form

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>\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";

Thank you

Upvotes: 0

Views: 656

Answers (1)

Marc B
Marc B

Reputation: 360762

Your html is broken:

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

Upvotes: 1

Related Questions