# PHP mail.php help

**URL:** <https://www.phphelp.com/t/php-mail-php-help/23423>\
**Category:** General PHP Help\
**Created:** [September 25, 2014, 1:06am UTC](https://www.phphelp.com/t/php-mail-php-help/23423 "2014-09-25T01:06:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://www.phphelp.com/uploads/default/original/2X/2/243e9ed5d93c5653ce3186f18df16e019ce38445.png) [@system](https://www.phphelp.com/u/system)\
**Post date:** [September 25, 2014, 1:06am UTC](https://www.phphelp.com/t/php-mail-php-help/23423/1 "2014-09-25T01:06:58Z")

</div>

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/](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

---

<div class="post-metadata">

**Author:** ![grwebugy](https://www.phphelp.com/user_avatar/www.phphelp.com/grwebugy/32/1076_2.png) [@grwebugy](https://www.phphelp.com/u/grwebugy)\
**Post date:** [September 27, 2014, 5:19pm UTC](https://www.phphelp.com/t/php-mail-php-help/23423/2 "2014-09-27T17:19:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![olidev](https://www.phphelp.com/letter_avatar_proxy/v4/letter/o/e5b9ba/32.png) [@olidev](https://www.phphelp.com/u/olidev)\
**Post date:** [August 10, 2018, 12:46pm UTC](https://www.phphelp.com/t/php-mail-php-help/23423/3 "2018-08-10T12:46:19Z")

</div>

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

```auto
<?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](https://www.cloudways.com/blog/custom-php-mysql-contact-form/). It is working.
