Log in

View Full Version : Resolved Form doesn't show completed fields in email



jhatter
11-06-2014, 09:37 AM
Hi,

I have adapted a form php script. I have just tested it and even though I filled all 3 fields out, the email I receive shows the first 2 as blank (FirstName & Surname).

Please can someone help me correct this? Thanks in advance!



<?php

$EmailFrom = "The Website";
$EmailTo = "me@mydomain.com";
$Subject = "A Message From Your Website";
$Name = Trim(stripslashes($_POST['FirstName']));
$Tel = Trim(stripslashes($_POST['Surname']));
$Email = Trim(stripslashes($_POST['Email']));

// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}

// prepare email body text
$Body = "";
$Body .= "FirstName: ";
$Body .= $FirstName;
$Body .= "\n";
$Body .= "Surname: ";
$Body .= $Surname;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$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=contactthanks.php\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>



<form method="post" action="contactengine.php">
<label for="Name"> * First Name:</label>
<input type="text" name="FirstName" id="FirstName" />

<label for="City"> * Surname:</label>
<input type="text" name="Surname" id="Surname" />

<label for="Email"> * Email:</label>
<input type="text" name="Email" id="Email" />


<input type="submit" name="submit" value="Submit" class="submit-button" />
</form>

jhatter
11-06-2014, 09:51 AM
I just worked it out myself - couldn't see the wood for the trees!