我有这个表格要通过电子邮件发送: http: //test4.bycustomdesign.com/order-form.shtml
表格效果很好。注意到我有一堆菜单列表选择框来选择不同的大小等。默认的初始选择始终是“选择”
我希望:如果用户没有选择任何内容,则可以发送表单。但是,在我收到的电子邮件中,如果用户没有选择任何内容,那么它就不会出现在电子邮件中。或者,如果它保留为默认的“选择”,那么它不应该出现在电子邮件中。因为并非所有字段都被选中,并且在电子邮件中我会得到一个很长的所有字段列表“选择”我希望通过只发送用户选择的任何内容来缩短它,而不是所有“选择”
请帮忙!谢谢你。米歇尔哈。这是我的代码:
// if the Email_Confirmation field is empty
if(isset($_POST['Email_Confirmation']) && $_POST['Email_Confirmation'] == ''){
// put your email address here
$youremail = 'bomandty@gmail.com, ryanjiles@betadiamond.com';
// prepare a "pretty" version of the message
$body .= "Thank you for your request. We will get back with you soon.";
$body .= "\n";
$body .= "\n";
foreach ($_POST as $Field=>$Value) {
if($Value != ''){
$body .= "$Field: $Value\n";
}
}
$CCUser = $_POST['EmailAddress'];
// Use the submitters email if they supplied one
// (and it isn't trying to hack your form).
// Otherwise send from your email address.
if( $_POST['EmailAddress'] && !preg_match( "/[\r\n]/", $_POST['EmailAddress']) ) {
$headers = "From: $_POST[EmailAddress]";
} else {
$headers = "From: $youremail";
}
// finally, send the message
mail($youremail, 'Request from BetaDiamonds.com', $body, $headers, $CCUser );
}
// otherwise, let the spammer think that they got their message through