Page 1 of 1

My form to email will not work!!

Posted: Thu Feb 11, 2010 5:20 am
by struggling
Hi, very new to PHP and wondering if anyone can help me please?!
I have an html form on my website and have just done a php form to email to go with it using online tutorials etc.
But it will not work!!
When I test it, it always says there is no email entered even though there is!!
Can anyone help me please?
Very grateful for any input!!

here is the code:

Code: Select all

 
 
<?php
 
 
$to = "me@myemail.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{"dogbreed"} = "Dog Breed" ;
 
$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.co.uk"; 
 
$subject2 = "Thank you for contacting us"; 
 
$autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at http://www.domain.co.uk";
 
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"; } 
 
}
 
}
 
 
?> 
 
 

Problem solved!!

Posted: Thu Feb 11, 2010 8:33 am
by struggling
After a few more hours of banging my head against the wall going over and over it again and again!!

... I realised it was actually a problem with the html form!!

All solved now though,

thank you