PHP mail.php help

Hi guys,
I am new and motivated to learn. I recently downloaded a template and I am yanking hair, trying to get this form to work.
I have followed this tutorial at http://www.1stwebdesigner.com/tutorials/custom-php-contact-forms/, and still no luck, keep getting a syntax error where the $subject = "Contact Form"; $mailheader = "From: $email \r\n"; mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); echo "Thank You!"; ?>

thanks guys

You didn’t post your form - did you include the data attributes on the fields?
“data-cfemail”

Otherwise, you could put some line breaks in the javascript to get a more specific location for the syntax error.

Check if you have created your PHP contact form script correctly or not. The contact form script should look something like this:

<?php 
require_once("config.php");
if((isset($_POST['your_name'])&& $_POST['your_name'] !='') && (isset($_POST['your_email'])&& $_POST['your_email'] !=''))
{
 require_once("contact_mail.php<strong>");
</strong>
$yourName = $conn->real_escape_string($_POST['your_name']);
$yourEmail = $conn->real_escape_string($_POST['your_email']);
$yourPhone = $conn->real_escape_string($_POST['your_phone']);
$comments = $conn->real_escape_string($_POST['comments']);

$sql="INSERT INTO contact_form_info (name, email, phone, comments) VALUES ('".$yourName."','".$yourEmail."', '".$yourPhone."', '".$comments."')";


if(!$result = $conn->query($sql)){
die('There was an error running the query [' . $conn->error . ']');
}
else
{
echo "Thank you! We will contact you soon";
}
}
else
{
echo "Please fill Name and Email";
}
?>

You can follow this guide here on php contact form. It is working.

Sponsor our Newsletter | Privacy Policy | Terms of Service