So I have a contact form on my website, which is partially working - The email is being sent to the intended email address, but the contents of the form are not included in the email. I do get the labels for the form inputs within the email, just not what the user inputs as their details.
I've examined and re-examined the variables and checked for typo's & syntax errors in the code but can't find any. PHP & js isn't my strong point so I'm hoping the kind & clever people here can point me in the right direction.
The HTML and js:
<form id="contact-form" name="contact-form" method="post" action="form-processing.php" style="float: right;">
<span id="sprytextfield1">
<label for="Name:">Name:</label>
<br />
<input name="Name" type="text" id="Name" tabindex="10" />
<span class="textfieldRequiredMsg">*</span></span>
<p><span id="sprytextfield2">
<label for="Email:">Email:</label>
<br />
<input type="text" name="Email" id="Email" tabindex="20"/>
<span class="textfieldInvalidFormatMsg">*</span></span>
</p>
<p><span id="sprytextfield3">
<label for="PhoneNumber">Phone Number:</label>
<br />
<input type="text" name="PhoneNumber" id="PhoneNumber" tabindex="30"/>
<span class="textfieldRequiredMsg">*</span></span>
<p><span id="sprytextfield4">
<label for="Message">Message:</label>
<br />
<textarea name="Message" cols="20" rows="10" id="Message" tabindex="40"></textarea>
<span class="textfieldRequiredMsg">*</span></span>
</p>
<p>
<input type="submit" name="Send" id="Send" value="Send" tabindex="50" />
</p>
</form>
<script type="text/javascript">
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "Name");
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "Email", {
isRequired: false
});
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "PhoneNumber", {
format: "phone_custom",
pattern: "07234567890",
validateOn: ["blur"]
});
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "Message");
</script>
The PHP code:
<?php
while (list($key, $val) = @each($_GET)) $GLOBALS[$key] = $val;
while (list($key, $val) = @each($_POST)) $GLOBALS[$key] = $val;
while (list($key, $val) = @each($_COOKIE)) $GLOBALS[$key] = $val;
while (list($key, $val) = @each($_FILES)) $GLOBALS[$key] = $val;
while (list($key, $val) = @each($_SESSION)) $GLOBALS[$key] = $val;
/* Subject and Email Variables */
$emailSubject = 'Website Contact Form';
$webMaster = 'jonnylovesspam@gmail.com';
/* Gathering Data Variables */
$nameField = $_POST['Name'];
$emailField = $_POST['Email'];
$PhoneNumberField = $_POST['PhoneNumber'];
$messageField = $_POST['Message'];
$body = <<<EOD
<br><hr><br>
Name: $nameField <br>
Email: $emailField <br>
Phone Numbers: $PhoneNumberField <br>
Message: $messageField <br>
EOD;
$headers = "From: $email
";
$headers = "Content-type: text/html
";
$success = mail($webMaster, $emailSubject, $body, $headers);
/* Results Rendered as HTML */
$theResults = <<<EOD
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><br />
<meta HTTP-EQUIV="REFRESH" content="0; url=contact-message-sent">
<style type="text/css">
<!--
body {
background-color: #fffff;
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #000000;
text-decoration: none;
}
-->
</style>
</head>
<div align="left">
Redirecting you...</div>
</body>
</html>
EOD;
echo "$theResults";
?>
You can see the form in action here: http://www.clearpandb.co.uk/contact
Thank you in advance for any pointers or help you can offer.