it come to my email id but i am getting this error...Syntax error '$names' 9T_VARIABLE) plz help me

here is my code

<? php

$names = $_POST['name'];
$visitor_email = $_POST['email'];
$visitor_phone_no = $_POST['phone'];
$message = $_POST['Message'];

$email_from = "rkenterprises9083@gmail.com";
$email_subject ="New Form Submission";
$email_body ="User Name: $names.\n".
"User Email: $visitor_email.\n".
"User Phnoe: $visitor_phone_no.\n".
"User message: $message.\n";

$to = "nishantverma040@gmail.com";
$headers = "From: $email_from \r\n";
$headers .= "Reply_To: $visitor-email \r\n";

mail($to,$email_subject,,$email_body,$headers);
header("Location: index.html");
?>

Recommended Answers

All 3 Replies

Hi,

What is the complete error message? PHP error messages typically say what line the error is on, etc.

In investigating the code above, the biggest things that stand out ot me are on line 17 you have the variable $visitor-email but I don't believe that dashes are allowed in variable names. Secondly, on line 19, you have two commas after $email_subject.

commented: It's Dani Lint. Is there a Lint checker for PHP? (Yes!) +15

this is the error......Parse error: syntax error, unexpected '$names' (T_VARIABLE) on line 4

Change the first line from <? php to <?php

You have a space between the ? and the php that needs to be removed. Also, make the other changes I wrote about earlier.

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.