我有一个报价表单,其中有一个下拉菜单,在提交表单后给我一个php致命错误。表单和值仍然通过电子邮件发送给我,但我收到此错误:PHP警告:为G中的foreach()提供的参数无效:在第60行.......任何帮助将不胜感激。这是我的下拉列表
<select name="item" id="item" >
<option value="Please Select" selected>Please Select</option>
<option value="Gold">Gold</option>
<option value="Silver">Silver</option>
<option value="Watch">Watch</option>
<option value="Electronics">Electronics</option>
<option value="Tools">Tools</option>
<option value="Lawn Equipment">Lawn Equipment</option>
<option value="Guns">Guns</option>
<option value="Musical Instrument">Musical Instrument</option>
<option value="Collectible">Collectible</option>
<option value="Other">Other</option>
</select>
这是我的php的一部分
<?php
$field_name = $_POST['name'];
$field_selectitem = $_POST['selectitem'];
$field_make = $_POST['make'];
$field_phone = $_POST['phone'];
$field_model = $_POST['model'];
$field_email = $_POST['email'];
$field_comments = $_POST['comments'];
if (isset($_POST['mailing'])) {
$checkBoxValue = "yes";
} else {
$checkBoxValue = "no";
}
//FORM DETAILS
$name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$item = $_POST['item']; // required
$make = $_POST['phone']; // required
$phone = $_POST['make'];
$model = $_POST['model'];
$comments = $_POST['comments']; // required
$mailing = $_POST['mailing'];
// Values from dropdown menu
echo'<select name="item">';
// For each value of the array assign variable name "items"
foreach($field_item as $key =>
$value){
echo"<option value=\"$key\">
$value</option>\n";
}
echo'</select>';
// FORM DETAILS EMAIL
$mail_to = 'highlandguns.contact@gmail.com';
$subject = 'Item Quote Request Form Results '.$name;
//EMAIL MESSAGE DETAILS
$body_message .= 'Name: '.$field_name."\n";
$body_message .= 'Email: '.$field_email."\n";
$body_message .= 'Phone: '.$field_phone."\n";
$body_message .= 'Item Type: '.$field_item."\n";
$body_message .= 'Make: '.$field_make."\n";
$body_message .= 'Model: '.$field_model."\n";
$body_message .= 'Comments: '.$field_comments."\n";
$body_message .= 'Join Mailing List:'.$checkBoxValue;
//EMAIL HEADERS
$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
?>
第60行错误是foreach($ field_item ..... =&gt;