PHP problem: Contact form validates fields but doesn't send the email upon submit.
If anyone can help with this I'd much appreciate it. Send a private message and I will forward the PHP file.
Oh yeah, I already ran a PHP test on my ISP directory and it returned the typical active state. ISP is currently supporting PHP 4.4.1 and MySQL 4.1.12.
PLEASE NOTE I REMOVED CLIENTS WEBSITE INCODE BELOW:
<?
// This is the begiinning of the PHP code
$name = $POST['name'];
$address = $POST['address'];
$state = $POST['state'];
$city = $POST['city'];
$zip = $POST['zip'];
$country = $POST['country'];
$phone = $POST['phone'];
$email = $POST['email'];
$comments = $POST['comments'];
$fax = $POST['fax'];
$error_msg = "";
$msg = "";
if(!$name){
$error_msg .= "Your name \n";
}
if($name){
$msg .= "Name: \t $name \n";
}
if($city){
$msg .= "City: \t $city \n";
}
if($country){
$msg .= "Country: \t $country \n";
}
if($phone){
$msg .= "Phone: \t $phone \n";
}
if(!$email){
$error_msg .= "Your email \n";
}
if($email){
if(!eregi("[a-zA-Z0-9.-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}", $email)){
echo "\n<br>That is not a valid email address. Please <a href=\"javascript:history.back()\">return</a> to the previous page and try again.\n<br>";
exit;
}
$msg .= "Email: \t $email \n";
}
if($subject){
$msg .= "Subject: \t $subject \n";
}
if($comments){
$msg .= "Comments: \t $comments \n";
}
$sender_email="";
if(!isset($name)){
if($name == ""){
$sender_name="Web Customer";
}
}else{
$sender_name=$name;
}
if(!isset($email)){
if($email == ""){
$sender_email="Customer@website.com";
}
}else{
$sender_email=$email;
}
if($error_msg != ""){
echo "You didn't fill in these required fields:<br>"
.nl2br($error_msg) .'<br>Please <a href="javascript:history.back()">return</a> to the previous page and try again.';
exit;
}
$mailheaders = "MIME-Version: 1.0\r\n";
$mailheaders .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$mailheaders .= "From: $sender_name <$sender_email>\r\n";
$mailheaders .= "Reply-To: $sender_email <$sender_email>\r\n";
mail("president@www.mywebsite.com","My Website Contact or Feedback",stripslashes($msg), $mailheaders);
header("Location: http://www.mywebsite.com/thankyou.html"); / Redirect browser /
//This is the end of the PHP code
?>