PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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!!
<?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"; }
}
}
?>
here is the code for the html form
(I have removed most of the options in the dropdown lists leaving just a few in each as there were millions!! otherwise left intact)