This is a contact form php script which i got from some site. But when i uploaded to site, it shows " parse syntax error" . Its somewhere between line 30 to 35. Please review it and find ou the error.


<?php
$EmailFrom = "contact@test.com";
$EmailTo = "root@localhost";
$Subject = "Contact Form";
$Name = $_POST;
$Email = $_POST;
$Phone = $_POST;
$Comments = $_POST;

// The body text of your email

$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "
";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "
";
$Body .= "Phone: ";
$Body .= $Phone;
$Body .= "
";
$Body .= "Comments: ";
$Body .= $Comments;
$Body .= "
";

// command that calls the php mail() function
$result = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirection as a function of $result variable boolean value
if ($result){
print "<meta http-equiv="refresh" content="0;URL=messagesent.html">";
}
else{
print "<meta http-equiv="refresh" content="0;URL=messagenotsent.html">";
}
?>

Hi there!

In your output part you need to escape the inner double-quotes like this:

if ($result){
print "<meta http-equiv=\"refresh\" content=\"0;URL=messagesent.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=messagenotsent.html\">";
}

A more in-depth explanation is given in the PHP documentation on strings.

Happy coding! :)

or you can use a single quote inside the double quotes

print "<meta http-equiv='refresh' content='0;URL=messagesent.html'>";

or you can use a single quote inside the double quotes

print "<meta http-equiv='refresh' content='0;URL=messagesent.html'>";

Thank you very much

Hi there!

In your output part you need to escape the inner double-quotes like this:

if ($result){
print "<meta http-equiv=\"refresh\" content=\"0;URL=messagesent.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=messagenotsent.html\">";
}

A more in-depth explanation is given in the PHP documentation on strings.

Happy coding! :)

Thanks for your reply

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.