Hi there,
I've been using a contact form on my website for years, and it has worked fine (server was running PHP4). Yesterday I moved to a new server running PHP5 and my contact form no longer works. It doesn't display any errors when used, it just doesn't work (i.e.) no email ever gets sent to me.
If anyone can take a look at the code and help me get it working, I'll be very grateful.
<?
$name = stripslashes($_POST['name']);
$email = stripslashes($_POST['email']);
$tel = stripslashes($_POST['phonenumber']);
$msg = stripslashes($_POST['message']);
$recipient = "info@mysite.com";
$subject = stripslashes("Inquiry (via mysite.com)");
$ccsubject = stripslashes("Inquiry (CC from mysite.com)");
$mailheaders = "From: $_POST[name] <$_POST[email]> \n";
$mailheaders .= "Reply-To: $_POST[email]";
$body = "Name: $name\n";
$body .= "Phone number: $tel\n\n";
$body .= "Message:\n$msg";
if (!isset($name) || !isset($email) || !isset($phonenumber) || !isset($message)) {
header( "Location: /" );
}
elseif (empty($name) || empty($email) || empty($phonenumber) ||empty($message)) {
header( "Location: /?msg=1#form" );
}
else {
mail($recipient, $subject, $body, $mailheaders);
header( "Location: /" );
if (isset($cc)) {
mail( $email, $ccsubject, $body, "From: info@mysite.com" );
}
header( "Location: /?msg=2#form" );
}
?>