Hi,
I have an html form page that a user fills out in which I want the results mailed to me.
I have a php page it refers to. Everything seems fine, but I do not receive the e-mail.
The code is below. Any suggestions?
Thanx
<?php
/* Set e-mail recipient */
$myemail = "example@example.com";
$subject = "ROH Consultation Results";
/* Check all form inputs using check_input function */
$question1 = check_input($_POST['question1'], "Please answer Question 1");
$question2 = check_input($_POST['question2'], "Please answer Question 2");
$question3A = check_input($_POST['question3A'], "Please answer Question 3");
$question3D = check_input($_POST['question3T'], "Please answer Question 3");
$question3T = check_input($_POST['question3D'], "Please answer Question 3");
$question3A = check_input($_POST['question3A'], "Please answer Question 3");
$question4D = check_input($_POST['question4D'], "Please answer Question 4");
$question4T = check_input($_POST['question4T'], "Please answer Question 4");
$question4A = check_input($_POST['question4A'], "Please answer Question 4");
$question5D = check_input($_POST['question5D'], "Please answer Question 5");
$question5T = check_input($_POST['question5T'], "Please answer Question 5");
$question5A = check_input($_POST['question5A'], "Please answer Question 5");
$question6D = check_input($_POST['question6D'], "Please answer Question 6");
$question6T = check_input($_POST['question6T'], "Please answer Question 6");
$question6A = check_input($_POST['question6A'], "Please answer Question 6");
$name = check_input($_POST['name'], "Please enter First and Last Name");
$email = check_input($_POST['email']);
$city = check_input($_POST['city'], "Please enter your City");
$state = check_input($_POST['state'], "Please enter your State");
$comment = check_input($_POST['comment'], "Write your comments");
$likeit = check_input($_POST['likeit']);
$how_find = check_input($_POST['how']);
/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
show_error("E-mail address not valid");
}
/* Let's prepare the message for the e-mail */
$message = "Hello!
Your contact form has been submitted by:
Name: $yourname
City: $city
State: $state
E-mail: $email
Question 1: $question1
Question 2: $question2
Question 3D: $question3D
Question 3T: $question3T
Question 3A: $question3A
Question 4D: $question4D
Question 4T: $question4T
Question 4A: $question4A
Question 5D: $question5D
Question 5T: $question5T
Question 5A: $question5A
Question 6D: $question6D
Question 6T: $question6T
Question 6A: $question6A
Like the website? $likeit
How did he/she find it? $how_find
Comments:
$comments
End of message
";
/* Send the message using mail() function */
mail($myemail, $subject, $message);
/* Redirect visitor to the thank you page */
header('Location: Thanks.htm');
exit();
/* Functions we used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<html>
<body>
<b>Please correct the following error:</b><br>
<?php echo $myError; ?>
<b></b>
<p>Please press the back arrow to make correction.</p>
</body>
</html>
<?php
exit();
}
?>