QUICK HELP with php contact form

I am having a difficult time processing a php contact form. Below is the html code and php script.

[code]
Your Name:


Your Email:


Your Message:



[/code]

[php]<?php

if (isset($_POST[‘name’]) && isset($_POST[‘email’]) && isset($_POST[‘message’])) {
$name = $_POST[‘name’];
$email = $_POST[‘email’];
$message = $_POST[‘message’];

if (!empty($name) && !empty($email) && !empty($message)) {

$to = '[email protected]';
$subject = 'Onedollarpic Message.';
$body = '$name."\n".$message';
$headers = 'From:'.$email;

if (mail($to, $subject, $body, $headers)) {
	echo 'Thanks for contacting us.';
} else {
	echo 'Sorry, an error has occurred. Please try again later';
}

} else
{
echo “All fields are required.”;
}

?>
[/php]

HTML form is on a separate page than the php script. What can you tell is wrong in the above code?

Appreciate your help.

Where exactly does the script seem to fail? From what I have looked over, everything should ok…

Well two things happen.

  1. On local server, i get this message when i click “Send”.
    Parse error: syntax error, unexpected ‘$’ in C:\xampp\htdocs\onedollarpic\contactform.php on line 2

  2. On the web server, i get no error or message when i click “send”. It simple shows an empty page (contactform.php).

Based on how you have your code setup I believe you are missing a } right after this line
[php]$message = $_POST[‘message’];[/php]
If you are needing a more complete contact form that is ready to go you can check out one that I distribute http://amecms.com/article/Easy-to-use-contact-form-with-validation

Wow, you are right. It works now.

Thank you!

Sponsor our Newsletter | Privacy Policy | Terms of Service