Contact form error?

Hi,

I have this on teflonpro1.com and it is saying it is encountering an error… is there something wrong in the code?

However it does send the confirmation email to the recipient.

[php] <?php
$to = $_REQUEST[‘[email protected]’] ;
$from = $_REQUEST[‘Email’] ;
$name = $_REQUEST[‘Name’] ;
$headers = “From: $from”;
$subject = “Web Contact Data”;

$fields = array();
$fields{“Name”} = “Name”;
$fields{“Company”} = “Company”;
$fields{“Email”} = “Email”;
$fields{“Phone”} = “Phone”;
$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: [email protected]”;
$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 www.teflonpro1.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.teflonpro1.com/contactus.html” );}
else
{print “We encountered an error sending your mail, please notify [email protected]”; }
}
}
?> [/php]

the html is

Department: General Support Sales Your Name:* Your E-mail:* Company: Phone:<input size=25 name="Phone" Subscribe to
mailing list: No Thanks
Yes, keep me informed
Your Message: A * indicates a field is required
ClearSend

What is the error message that it is giving you?

You’re array is setup wrong. should be

$fields = array();
$fields[“Name”] = “Name”;
$fields[“Company”] = “Company”;
$fields[“Email”] = “Email”;
$fields[“Phone”] = “Phone”;
$fields[“list”] = “Mailing List”;
$fields[“Message”] = “Message”;

The if statements are setup wrong, should be
[php]
if(empty($from)) {
$error = true;
$err[‘from’] = “You have not entered an email, please go back and try again”;
} else {
$from = $_POST[‘from’]; // change your field name
}
if(empty($name)) {
$error = true;
$err[‘name’] = “You have not entered a name, please go back and try again”;
} else {
$name = $_POST[‘name’]; // change to your field name
}
if(!$error) {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send) {
header(“Location: http://www.teflonpro1.com/contactus.html”);
} else {
print “We encountered an error sending your mail, please notify [email protected]”;
}
}
} // not sure what this goes to[/php]

To display the errors, you either call them by the key or by using a loop, depending on how you have the errors being displayed.

I added some things in there, like the error messages. Use it or not, doesn’t matter, won’t affect the script, just remove the if($error) if you choose to not use it.

you missed a quote off the email value…

Fixed

:wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service