复选框内容未显示在php中邮件的html内容中
我试图将复选框的数据存储在数据库中,并在提交包含复选框内容的表单后向用户发送邮件。但是,复选框内容在邮件中不可见。帮我解决这个问题 HTML代码:复选框内容未显示在php中邮件的html内容中,php,html,sql,email,phpmailer,Php,Html,Sql,Email,Phpmailer,我试图将复选框的数据存储在数据库中,并在提交包含复选框内容的表单后向用户发送邮件。但是,复选框内容在邮件中不可见。帮我解决这个问题 HTML代码: <div class="row"> <div class="col-4"> <div class="form-check"> <label class="form-check-label"> <input class="form-check-input" na
<div class="row">
<div class="col-4">
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" name="event[]" type="checkbox" value="All Events">
<span style="font-size: 15px;">All Events</span>
</label>
</div>
</div>
<div class="col-4">
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" name="event[]" type="checkbox" value="Wine Tasting Event">
<span style="font-size: 15px;">Wine Tasting </span>
</label>
</div>
</div>
<div class="col-4">
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" name="event[]" value="Shopping Event">
<span style="font-size: 15px;">Shopping </span>
</label>
</div>
</div>
<div class="col-4">
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" name="event[]" value="Basketball Charity Event">
<span style="font-size: 15px;">Basketball Charity </span>
</label>
</div>
</div>
<div class="col-4">
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" name="event[]" value="As Needed">
<span style="font-size: 15px;">As Needed</span>
</label>
</div>
</div>
义工邮件功能:
function volunteer_mail(){
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = email;
$mail->Password = pass;
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->setFrom(email, 'Detroit Pheniox Center');
$mail->addAddress($_POST['email']); // Add a recipient
$mail->isHTML(true);
$mail->Subject = 'Volunteer Registration Confirmation';
$mail->Body = '<html>
<body style="font-family:Georgia, serif; ">
<center>
<div style="width:500px;background-color:#f5f5f5;border: 1px
solid #a8a8a8; padding:20px; border-radius:2px;">
<img src="https://scontent-ort2- 2.cdninstagram.com/vp/dab330c3a04b24bb987abed742147509/5B8ABB80/t51.2885-19/s150x150/26873078_409153092875319_57809469530177536_n.jpg" height="100" width="100" style="border-radius:100%;">
';
$sql = "SELECT * FROM volunteers WHERE email='$email';";
$result = mysqli_query($conn, $sql);
While($row = mysqli_fetch_assoc($result))
{
$event_array = explode(",", $row['event_name']);
$count = count($event_array);
for($i=0;$i<$count;$i++){
$mail->Body .= '<h4>'. $event_array[$i] . ' </h4>';
}
}
$mail->Body .='<h3>Hello! '.$_POST['first-name'].'</h3>
<h3>THANK YOU!</h3> for joining as a volunteer and helping us in the
event.
<p> Looking forward to meet you in the event. </p>
<div style="padding:20px;background-color: #2c3840;">
<a href="http://www.detroitphoenixcenter.org/index.html"
style="color:white;">OurWebsite</a> <a
href="https://www.instagram.com/detroitphoenixcenter/"
style="color:white;">Intsagram</a> <a
href="https://www.linkedin.com/company/detroit-phoenix-center"
style="color:white;">Linkedin</a>
</div>
</div>
</center>
</body>
</html> ';
$mail->AltBody = 'This is the body in plain text for non-HTML mail
clients';
$mail->send();
}
功能志愿者邮件(){
$mail=新的PHPMailer;
$mail->isSMTP();
$mail->Host='smtp.gmail.com';
$mail->SMTPAuth=true;
$mail->Username=电子邮件;
$mail->Password=pass;
$mail->SMTPSecure='tls';
$mail->Port=587;
$mail->setFrom(电子邮件“底特律菲尼克斯中心”);
$mail->addAddress($_POST['email']);//添加收件人
$mail->isHTML(true);
$mail->Subject='志愿者注册确认';
$mail->Body=
';
$sql=“从志愿者中选择*,其中email='$email';”;
$result=mysqli\u查询($conn,$sql);
While($row=mysqli\u fetch\u assoc($result))
{
$event_array=explode(“,”,$row['event_name']);
$count=count($event\u数组);
对于($i=0;$iBody.='.$event_数组[$i].';
}
}
$mail->Body.='Hello!'.$\u POST['first-name']
谢谢你!作为一名志愿者加入并帮助我们完成这项任务
事件
期待在活动中与您见面
';
$mail->AltBody='这是非HTML邮件的纯文本正文
客户的;
$mail->send();
}
当完成此邮件功能时,我正在接收邮件,但未显示事件复选框内容,剩余的html将按照in代码显示。请帮助我。事件数据是否存储在DB中?实际上,你可以看到,在html中,我存储在事件数组中,并以字符串形式存储在DB中。它正在成功存储,但未在ma上显示我会打印($mail->body)并在发送电子邮件之前退出,然后检查数据是否正在打印
function volunteer_mail(){
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = email;
$mail->Password = pass;
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->setFrom(email, 'Detroit Pheniox Center');
$mail->addAddress($_POST['email']); // Add a recipient
$mail->isHTML(true);
$mail->Subject = 'Volunteer Registration Confirmation';
$mail->Body = '<html>
<body style="font-family:Georgia, serif; ">
<center>
<div style="width:500px;background-color:#f5f5f5;border: 1px
solid #a8a8a8; padding:20px; border-radius:2px;">
<img src="https://scontent-ort2- 2.cdninstagram.com/vp/dab330c3a04b24bb987abed742147509/5B8ABB80/t51.2885-19/s150x150/26873078_409153092875319_57809469530177536_n.jpg" height="100" width="100" style="border-radius:100%;">
';
$sql = "SELECT * FROM volunteers WHERE email='$email';";
$result = mysqli_query($conn, $sql);
While($row = mysqli_fetch_assoc($result))
{
$event_array = explode(",", $row['event_name']);
$count = count($event_array);
for($i=0;$i<$count;$i++){
$mail->Body .= '<h4>'. $event_array[$i] . ' </h4>';
}
}
$mail->Body .='<h3>Hello! '.$_POST['first-name'].'</h3>
<h3>THANK YOU!</h3> for joining as a volunteer and helping us in the
event.
<p> Looking forward to meet you in the event. </p>
<div style="padding:20px;background-color: #2c3840;">
<a href="http://www.detroitphoenixcenter.org/index.html"
style="color:white;">OurWebsite</a> <a
href="https://www.instagram.com/detroitphoenixcenter/"
style="color:white;">Intsagram</a> <a
href="https://www.linkedin.com/company/detroit-phoenix-center"
style="color:white;">Linkedin</a>
</div>
</div>
</center>
</body>
</html> ';
$mail->AltBody = 'This is the body in plain text for non-HTML mail
clients';
$mail->send();
}