Hi guys,
Please help me sort this annoying problem. Im new to the forum and quite new to Php.. weren't we all?
My problem is, i have this code set up to send a form. However, when the form is completed and submitted it returns the error message i have written saying no email has been completed. The funny thing is though...it sends the email.
this is my code:
<?php $to = $_REQUEST['sendto'] ;
$from = $_REQUEST['Email'] ;
$name = $_REQUEST['Name'] ;
$headers = "From: $from";
$subject = "Booking Request";
$fields = array();
$fields{"Name"} = "Name";
$fields{"Address"} = "Address";
$fields{"District"} = "District";
$fields{"Town"} = "Town";
$fields{"Postcode"} = "Postcode";
$fields{"Phone"} = "Phone";
$fields{"Email"} = "Email";
$fields{"list"} = "Mailing List";
$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: noreply@YourCompany.com";
$subject2 = "Thank you for contacting us";
if($from == '')
{echo "You have not entered an email, please go back and try again";}
else
{ if($name == '')
{echo "You have not entered your name, please go back and try again";}
else
{ $send = mail($to, $subject, $body, $headers);
if($send) {header( "Location: http://www.21stcenturyportraits.com/emailresponse.php" );}
else
{print "We encountered an error sending your mail, please notify webmaster@YourCompany.com"; } } } ?>
As I said, the problem seems to be with my If statements, even though I enter an email address it shows my error message.
Regards
Rich