I have a form that allows people to request a free eBook. The form details will be sent to an admin, upon return they will email the eBook to the user. I need to be able to show in this "system" email whether the user gave consent to be manually subscribed to the newsletter or not.
The checkbox is there, checked as the default state.
Here is the system mail I receive after submitting the form:
--
Name: Aniska
Surname: Berry
Email: nissberry@gmail.com
Residential: Ballito
Newsletter:
--
^As you can see the "Newsletter" value is empty - I need to be able to see here whether the user gave consent or not. (Whether the box was checked or not)
Here is my form:
<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>
And here is my 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://ift.tt/1uevO3U\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
Aucun commentaire:
Enregistrer un commentaire