I have a HTML form, powered by PHP on a website, however I am having problems with it as I am new to PHP, and for some reason the form response is not being received.
The php code I am using is:
Code: Select all
<?php
$errors = '';
$myemail = 'email@domain.com';//<-----Put Your email address here.
if(empty($_POST['FirstName']) ||
empty($_POST['LastName']) ||
empty($_POST['Phone']) ||
empty($_POST['Email']) ||
empty($_POST['Enquiry']))
{
$errors .= "\n Error: all fields are required";
}
$FirstName = $_POST['FirstName'];
$LastName = $_POST['LastName'];
$Phone = $_POST['Phone'];
$Email = $_POST['Email'];
$Enquiry = $_POST['Enquiry'];
if (!eregi(
"^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",
$Email))
{
$errors .= "\n Error: Invalid email address";
}
if( empty($errors))
{
$to = $myemail;
$email_subject = "Website Enquiry";
$email_body = "Website Enquiry ".
" Here are the details:\n Name: $FirstName \n $LastName \n Day Phone: $Phone \n Email: $Email \n Enquiry \n $Enquiry";
$headers = "From: $myemail";
$headers .= "Reply-To: $Email";
mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
header('Location: http://www.earnosethroat.com.au/success.html');
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Error</title>
</head>
<body>
<!-- This page is displayed only if there is some error -->
<?php
echo nl2br($errors);
?>
</body>
</html>If anyone can help me work out why I am not receiving it, would be much appreciated.
Thanks
Bec