Help with integrated "Contact Me" Form

Hi guys,

Would you please help in discoring what’s wrong with this contact form? It displays no message and sends nada…

I’d be very grateful. ;D

[php]<?php
if (isset($_POST[“submit”])) {
$name = $_POST[‘name’];
$email = $_POST[‘email’];
$message = $_POST[‘message’];
$from = ‘Fares WebDev’;
$to = ‘[email protected]’;
$subject = 'Message from Contact Demo ';

    $body = "From: $name\n E-Mail: $email\n Message:\n $message";

    // Check if name has been entered
    if (!$_POST['name']) {
        $errName = 'Please enter your name';
    }
    
    // Check if email has been entered and is valid
    if (!$_POST['email'] || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
        $errEmail = 'Please enter a valid email address';
    }
    
    //Check if message has been entered
    if (!$_POST['message']) {
        $errMessage = 'Please enter your message';
    }

// If there are no errors, send the email
if (!$errName && !$errEmail && !$errMessage && !$errHuman) {
if (mail ($to, $subject, $body, $from)) {
$result=‘

Thank You! I will be in touch
’;
} else {
$result=‘
Sorry there was an error sending your message. Please try again later
’;
}
}
}
?>
<?php echo $result; ?>[/php]

First, I removed your email address from your post! Robots scan these sites for email addresses and you should never post
them inside forum sites unless sent inside a private-message from member-to-member.

Now, you did not set up your HEADERS in the email before sending them out. Headers are needed in all emails and must be
set up in a certain manner. It depends your server and several other options. But, here is a sample, not using your data, just
an example:
[php]
$to = ‘[email protected]’;
$subject = ‘the subject’;
$message = ‘hello’;
$headers = ‘From: [email protected]’ . “\r\n” .
‘Reply-To: [email protected]’ . “\r\n” .
‘X-Mailer: PHP/’ . phpversion();

mail($to, $subject, $message, $headers);
[/php]
As you see, your FROM is really the header, but, is not in the correct format. Try it and if it fails let us know…

Sponsor our Newsletter | Privacy Policy | Terms of Service