I know this is a simple thing I am overlooking but I cannot seem to find it.
When I test my form I am getting this error
We are very sorry, but there were error(s) found with the form you submitted. These errors appear below.
The Message you entered does not appear to be valid.
Please go back and fix these errors.
Here is the form code
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "myemail@gmail.com";
$email_subject = "Submission Form";
function died($error) {
// your error code can go here
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['name']) ||
!isset($_POST['email']) ||
!isset($_POST['subject']) ||
!isset($_POST['message'])) {
died('We are sorry, but there appears to be a problem with the form you
submitted.');
}
$name = $_POST['name']; // required
$email = $_POST['email']; // required
$subject = $_POST['subject']; // required
$message = $_POST['message']; // required
$error_message = "";
$string_exp = "/^[A-Za-z0-9 .'-]+$/";
if(!preg_match($string_exp,$name)) {
$error_message .= 'The Name you entered does not appear to be valid.<br />';
}
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$subject)) {
$error_message .= 'The Subject you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$message)) {
$error_message .= 'The Message you entered does not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message .= "Name: ".clean_string($name)."\
";
$email_message .= "Email: ".clean_string($email)."\
";
$email_message .= "Subject: ".clean_string($subject)."\
";
$email_message .= "Message: ".clean_string($message)."\
";
// create email headers
$headers = 'From: '.$email_from."\\r\
".
'Reply-To: '.$email_from."\\r\
" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
header('Location: thank-you.html');
}
?>
Like I said, I know I am looking over something.