Help With Parse Error

blackhataffiliate

Senior Member
Joined
Oct 19, 2008
Messages
847
Reaction score
1,372
Okay, here is a basic contact form. I keep getting the following parse error. I know it is something simple, but I cant find it. Can some one please help me figure this out, it is driving me crazy.

Error is Parse error: syntax error, unexpected '@' in............contact/sendmail.php on line 16

Code:
<?php
if(isset($_POST['submit'])) {

$to = "email";
$subject = "Contact Form Results";
$name_field = $_POST['sender_name'];
$email_field = $_POST['sender_email'];
$message = $_POST['message'];
 
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";
 
echo "Data has been submitted to $to!";
mail($to, $subject, $body);

else {

echo "Thank you for contacting us. Please allow up to 48 business hours for a reply!";

}
?>
 
Miss a '}'.

This should work:
Code:
<?php
if(isset($_POST['submit'])) {

$to = "email";
$subject = "Contact Form Results";
$name_field = $_POST['sender_name'];
$email_field = $_POST['sender_email'];
$message = $_POST['message'];
 
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";
 
echo "Data has been submitted to $to!";
mail($to, $subject, $body);

}

else {

echo "Thank you for contacting us. Please allow up to 48 business hours for a reply!";

}
?>
 
Thanks for your help. If you only knew how long I looked for that. I am new to php and the simplest error gets me hung up for ever.
 
You welcome. You can use a editor that shows that kind of errors. I use the PHP Eclipse editor. It 's a very good help.
 
Back
Top