The issue is I am submitting the form and it is saying it is correctly run, but I have not received email with the submission.
Can anyone assist as to why this is not happening?
Thanks
Paul
:bemused:
The Form Itself
<form name="contactform" action="send_form_email.php" method="post">
<tr>
<td align="right">Title</td>
<td align="left"><select name="Title" tabindex="1">
<option value="Mr" >Mr</option>
<option value="Mrs">Mrs</option>
<option value="Miss">Miss</option>
<option value="Dr">Dr</option>
<option value="Ms">Ms</option>
</select></td>
<td rowspan="12" align="left"><fieldset>
<legend>Description</legend>
<p>
<label for="comments"></label>
<textarea name="comments" id="comments" cols="25" rows="14" tabindex="12"></textarea>
</p>
</fieldset></td>
</tr>
<tr>
<td align="right">First Name</td>
<td align="left"><input name="First_Name" type="text" size="25" maxlength="30" tabindex="2"/></td>
</tr>
<tr>
<td align="right">Surname</td>
<td align="left"><input name="Surname" type="text" size="25" maxlength="30" tabindex="3"/></td>
</tr>
<tr>
<td align="right">House No / Name</td>
<td align="left"><input name="House_NameNo" type="text" size="25" maxlength="30" tabindex="4"/></td>
</tr>
<tr>
<td align="right">Street</td>
<td align="left"><input name="Street" type="text" size="35" maxlength="40" tabindex="5"/></td>
</tr>
<tr>
<td align="right">Town/City</td>
<td align="left"><input name="Town_City" type="text" size="35" maxlength="40" tabindex="6"/></td>
</tr>
<tr>
<td align="right">County</td>
<td align="left"><input name="County" type="text" size="25" maxlength="30" tabindex="7"/></td>
</tr>
<tr>
<td align="right">Post Code</td>
<td align="left"><input name="Post_Code" type="text" size="10" maxlength="15" tabindex="8"/></td>
</tr>
<tr>
<td align="right">Phone Number</td>
<td align="left"><input name="Phone" type="text" size="25" maxlength="30" tabindex="9"/></td>
</tr>
<tr>
<td align="right">Email address</td>
<td align="left"><input name="email" type="text" size="35" maxlength="35" tabindex="10"/></td>
</tr>
<tr>
<td align="right">Preferred Contact time</td>
<td align="left"><select name="contact" tabindex="11">
<option value="Morning" >Morning</option>
<option value="Afternoon">Afternoon</option>
<option value="Evening">Evening</option>
</select></td>
</tr>
<tr>
<td></td>
<td align="left"><input name="submit" type="submit" value="Submit" tabindex="13"/></td>
</tr>
</form>
The processing page
<?php
if(isset($_POST['email'])) {
$email_to = "me@masked.com";
$email_subject = "Website Enquiry";
function died($error) {
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['Title']) ||
!isset($_POST['First_Name']) ||
!isset($_POST['Surname']) ||
!isset($_POST['House_NameNo']) ||
!isset($_POST['Street']) ||
!isset($_POST['Town_City']) ||
!isset($_POST['County']) ||
!isset($_POST['Post_Code']) ||
!isset($_POST['Phone']) ||
!isset($_POST['email']) ||
!isset($_POST['contact']) ||
!isset($_POST['comments'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$title = $_POST['Title'];
$first_name = $_POST['First_Name']; // required
$last_name = $_POST['Surname']; // required
$house = $_POST['House_NameNo'];
$street = $_POST['Street'];
$town = $_POST['Town_City'];
$county = $_POST['County'];
$postcode = $_POST['Post_Code'];
$phone = $_POST['Phone'];
$email_from = $_POST['email']; // required
$contact = $_POST['contact'];
$comments = $_POST['comments']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$title)) {
$error_message .= 'The title you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'The Surname you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$house)) {
$error_message .= 'The house name or number you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$street)) {
$error_message .= 'The Street you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$town)) {
$error_message .= 'The Town you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$county)) {
$error_message .= 'The County you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Title: ".clean_string($title)."\n";
$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Surname: ".clean_string($last_name)."\n";
$email_message .= "House Name / No: ".clean_string($house)."\n";
$email_message .= "Street: ".clean_string($street)."\n";
$email_message .= "Town / City: ".clean_string($town)."\n";
$email_message .= "County: ".clean_string($county)."\n";
$email_message .= "Post Code: ".clean_string($postcode)."\n";
$email_message .= "Phone Number: ".clean_string($phone)."\n";
$email_message .= "Email Address: ".clean_string($email_from)."\n";
$email_message .= "Contact Preference: ".clean_string($contact)."\n";
$email_message .= "Comments: ".clean_string($comments)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($email_to, $email_subject, $email_message, $headers);
?>
Thank you for contacting us. We will be in touch with you very soon.
<?php
}
?>