This code i use for my contact form. but when i received from my email
This is result:

Email:  <br>
Name:  <br>
Phone number:  <br>
Comments:  <br>

This is PHP code. Can someone help me fix and explain why. Thanks for your support.

<?php

/* Subject and Email Variable*/

$emailSubject = 'Email from Clients';
$to = 'tracyn2k2@yahoo.com';

/* Gathering Data Variables */


	$nameField = $_POST['name'];
	$emailField = $_POST['email'];
	$phonenumberField = $_POST['phonenumber'];
	$commentsField = $_POST['comments'];
	
	$body = <<<EOD
Email: $email <br>
Name: $name <br> 
Phone number: $phonenumber <br>
Comments: $comments <br>
EOD;
			 
	$header = "From: $email\r\n";
	$headers .= "Content-type: text/html\r\n";
	$success = mail($to, $emailSubject, $body, $header);
	
/* Result sender */
	
echo "Your Email sent to us. Thank for your inquiries. We will reply you within 24 hours";
?>

Try changing your script to as follows as some of your variables were difined with the wrong name:

<?php

/* Subject and Email Variable*/

$emailSubject = 'Email from Clients';
$to = 'tracyn2k2@yahoo.com';

/* Gathering Data Variables */


$name = $_POST['name'];
$email = $_POST['email'];
$phonenumber = $_POST['phonenumber'];
$comments = $_POST['comments'];

$body = <<<EOD
Email: $email <br>
Name: $name <br> 
Phone number: $phonenumber <br>
Comments: $comments <br>
EOD;

$header = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($to, $emailSubject, $body, $header);

/* Result sender */

echo "Your Email sent to us. Thank for your inquiries. We will reply you within 24 hours";
?>

And if nessecary you can use the following:

<?php

/* Subject and Email Variable*/

$emailSubject = 'Email from Clients';
$to = 'tracyn2k2@yahoo.com';

/* Gathering Data Variables */


$name = $_POST['name'];
$email = $_POST['email'];
$phonenumber = $_POST['phonenumber'];
$comments = $_POST['comments'];

$body = "Email: ".$email." <br>
Name: ".$name." <br> 
Phone number: ".$phonenumber." <br>
Comments: ".$comments." <br>";

$header = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($to, $emailSubject, $body, $header);

/* Result sender */

echo "Your Email sent to us. Thank for your inquiries. We will reply you within 24 hours";
?>

Hope that helps ya.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.