form to email not delivering
Posted: Fri Feb 12, 2010 5:30 am
I have a contact form to email php that is not working!
It directs to the thankyou page as if it has worked and sends the client a thankyou email saying we will be in touch - only we wont because it hasn't actually sent us the information!!
No e-mail is recieved by us at all??!!
Please can anyone help me? I don't know what I'm doing wrong!!
Here is the PHP Code:
It directs to the thankyou page as if it has worked and sends the client a thankyou email saying we will be in touch - only we wont because it hasn't actually sent us the information!!
No e-mail is recieved by us at all??!!
Please can anyone help me? I don't know what I'm doing wrong!!
Here is the PHP Code:
Code: Select all
<?php
$to = "admin@domain.com" ;
$from = $_REQUEST['email'] ;
$name = $_REQUEST['name'] ;
$headers = "From: $from" ;
$subject = "Contact Form Data" ;
$fields = array();
$fields{"name"} = "Name" ;
$fields{"email"} = "Email" ;
$fields{"telephone"} = "Telephone" ;
$fields{"town"} = "Town" ;
$fields{"breed"} = "Breed" ;
$fields{"trainingclasses"} = "Interested In Training Classes?" ;
$fields{"kennelclubscheme"} = "Interested In kennel Club Scheme?" ;
$fields{"agility"} = "Interested In Agility?" ;
$fields{"behaviourconsultation"} = "Interested In Behaviour Consultation?" ;
$fields{"dogprofiling"} = "Interested In Dog Profiling?" ;
$fields{"raf"} = "Interested in RAF?" ;
$fields{"message"} = "Message" ;
$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
$headers2 = "From: admin@domain.com";
$subject2 = "Thank you for contacting us";
$autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usually within 48 hours. If you have any more questions, please consult our website at http://www.domain.com";
if($from == '') {print "You have not entered an email, please go back and try again";}
else {
if($name == '') {print "You have not entered a name, please go back and try again";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( "Location: http://www.domain.com/thankyou.html" );}
else
{print "We encountered an error sending your mail, please notify webmaster@domain.com"; }
}
}
?>