【发布时间】:2014-06-05 07:19:48
【问题描述】:
由于我对 PHP 的了解不足,无法在邮件正文中添加多个复选框值。
我知道可以使用foreach 循环按数组显示/echo 复选框,但我不知道在邮件正文中显示echo。我想在$message 中回显它。
HTML 代码示例-
<input type="checkbox" name="color[]" value="Value1"> Title1
<input type="checkbox" name="color[]" value="Value2"> Title2
<input type="checkbox" name="color[]" value="Value3"> Title3
<input type="checkbox" name="color[]" value="Value4"> Title4
<input type="checkbox" name="color[]" value="Value5"> Title5
PHP代码-
<?php
$to = "arifkpi@gmail.com";
$fromEmail = "arif@arif-khan.net";
$fromName = "Arif Khan";
$subject = "Contact Email";
$message = "Hey, Someone Sent you a Contact Message through your Website.
Details Below-
Name: $_POST[fname] $_POST[lname]
Email Address: $_POST[email]
Contact Number: $_POST[contact1] $_POST[contact2] $_POST[contact3]
Zip Code: $_POST[zip]
Best Time To Contact: $_POST[besttime]
Payment Plan Options: $_POST[payment_plan]
MUA: $_POST[mua]
Shoot Concept:
Shoot Concept(Other): $_POST[shootother]";
$headers = "From:" . $fromName . " " . $fromEmail;
$flgchk = mail ("$to", "$subject", "$message", "$headers");
if($flgchk){
echo "A email has been sent to: $to";
}
else{
echo "Error in Email sending";
}
?>
【问题讨论】: