【发布时间】:2013-09-09 16:33:42
【问题描述】:
我有一个表格,每行都显示有复选框,用户可以选择多个复选框然后单击提交,然后这将使用 phpmailer 发送电子邮件。 我希望用户选择的项目包含在电子邮件正文中。我知道以下内容是错误的,但有人可以告诉我如何做到这一点吗?
这是我目前所拥有的......它确实发送了一封电子邮件,但只有数组中的第一个选择在正文中。
$select = $_POST['select'];
if(empty($select))
{
echo("You didn't make any selections.");
}
else
{
$count = count($select);
for($i=0; $i < $count; $i++)
{
$to = "test@test.com";
$subject = "Booking Reguest";
$message = '
<html>
<head>
<title>Booking Request</title>
</head>
<body>
<p>Please create bookings for the following ...</p>
<p>'. $select[$i] .',</p>
<p>Kind regards</p>
<p>blah blah blah</p>
</body>
</html>';
$headers = 'From: noreply@test.com' . "\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to,$subject,$message,$headers);
}
}
感谢您的帮助!
【问题讨论】: