我有一个允许人们申请免费电子书的表单。表单详细信息将发送给管理员,返回后,他们会将电子邮件通过电子邮件发送给用户。我需要能够在这个“系统”电子邮件中显示用户是否同意手动订阅时事通讯。
复选框在那里,检查为默认状态。
以下是我在提交表单后收到的系统邮件:
-
姓名:Aniska
姓:Berry
电子邮件:nissberry@gmail.com
住宅:Ballito
通讯:
-
^正如您所看到的“时事通讯”值为空 - 我需要能够在此处看到用户是否同意。 (是否检查了盒子)
这是我的表格:
<form method="POST" id="contact-form" class="form-inline" action="contactengine.php" onSubmit="alert('Thank you for your feedback!');">
<div class="form-group white-text">
<label>Name</label>
<input type="text" name="Name" id="Name" class="form-control wow fadeInUp" placeholder="Name" required/>
</div>
<div class="form-group white-text">
<label>Surname</label>
<input type="text" name="Surname" id="Surname" class="form-control wow fadeInUp" placeholder="Surname" required/>
</div>
<div class="form-group white-text m-t">
<label>Email address</label>
<input type="text" name="Email" id="Email" class="form-control wow fadeInUp" placeholder="Email" required/>
</div>
<div class="form-group white-text m-t">
<label>Residential Area</label>
<input type="text" name="Residential" id="Residential" class="form-control wow fadeInUp" placeholder="Residential Area" required/>
</div>
<div class="form-group checkbox white-text">
<label>
<input name="newsletter" type="checkbox" class="checked" checked>Consent
</label>
</div>
<div class="form-group m-t m-b">
<input type="submit" name="submit" value="Please send me my EBook!" class="btn-primary wow fadeInUp" />
</div>
</form>
这是我的php
<?php
$EmailFrom = "admin@webmaster.com";
$EmailTo = "nissberry@gmail.com";
$Subject = "eBook request from User";
$Name = Trim(stripslashes($_POST['Name']));
$Surname = Trim(stripslashes($_POST['Surname']));
$Email = Trim(stripslashes($_POST['Email']));
$Residential = Trim(stripslashes($_POST['Residential']));
$Newsletter = Trim(stripslashes($_POST['Newsletter']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Surname: ";
$Body .= $Surname;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Residential: ";
$Body .= $Residential;
$Body .= "\n";
$Body .= "Newsletter: ";
$Body .= $Newsletter;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.remax-panache.co.za\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
答案 0 :(得分:0)
您不能以这种方式使用复选框。使用这种方式:
$Newsletter = isset($_POST['Newsletter']) ? true : false;
$Newsletter = isset($_POST['Newsletter']) ? "Yes" : "No";
上述任何一种都应该有效。当您POST
复选框时,它会以这种方式发布:
name=on
(empty)
不发布任何内容。