0

I have an error. it says:

syntax error, unexpected end of file

<?php
{
if($_POST["submit']) {
    $recipient=\"youremail@gmail.com\";
    $subject=\"Inquiry Form\";
    $sender=$_POST [name];
    $senderEmail=$_POST [email];
    $FeedbackQuestion=$_POST [feedback];

$mailBody=\"Name: $name\nEmail:$email\n\n$feedback;

\mail($recipient, $subject, $mailbody, \"From: $name<$email>\");

$thankYou=\"Thank you! Your message has been sent.\";

} 
?>

What's the problem?

Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98
user9255818
  • 19
  • 1
  • 3
  • 1
    Please post your error code and take a look at [how to ask](https://stackoverflow.com/help/how-to-ask). – creyD Jan 23 '18 at 09:18
  • There are plenty of IDEs available for PHP like Eclipse, Netbeans. These editors show you the error right at code level. – Pupil Jan 23 '18 at 09:20
  • Also, in the question itself, while block below `if`is showing syntax highlighted. Why didn't you get your error? – Pupil Jan 23 '18 at 09:21
  • Possible duplicate of [Reference - What does this error mean in PHP?](https://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) – Chetan Ameta Jan 23 '18 at 09:25

1 Answers1

2

replace if($_POST["submit']) { with if($_POST["submit"]) {

see the different " instead of ' after submit

And then, remove the first { at line 2.

The complete correct code is:

<?php
if($_POST["submit"])
{
    $recipient="youremail@gmail.com";
    $subject="Inquiry Form";
    $sender=$_POST ['name'];
    $senderEmail=$_POST ['email'];
    $FeedbackQuestion=$_POST ['feedback'];

    $mailBody="Name: $name\nEmail:$email\n\n$feedback";

    mail($recipient, $subject, $mailbody, "From: $name<$email>");

    $thankYou="Thank you! Your message has been sent.";
}
?>

Also all the \" must be replaced with " because the \" is needed only inside strings enclosed by ".

Also, the arrays keys must be enclosed by '.

user2342558
  • 5,567
  • 5
  • 33
  • 54