-1

here is the php code that is in an html form and whenever i run it i get this error: Parse error: syntax error, unexpected variable "$body" in C:\Users\LUNIV\LUNIVII\index.php on line 15

<?php
  $message_sent = false;
  if(isset($_POST['lname']) && $_POST['lname'] != ''){

    if(filter_var($_POST['lname'], FILTER_VALIDATE_EMAIL)){
        echo "<pre>";
        print_r($_POST);
        echo "<pre>";
        $name = $_POST['fname'];
        $email = $_POST['lname'];
        $story = $_POST['story'];

        $email_to = "lunivii@outlook.com";
        $body = "";
        

        $body .= "From: ". $name. "\r\n";
        $body .= "Email: ". $email. "\r\n";
        $body .= "Message: ". $story. "\r\n";

        mail($email_to,$email,$story);

        $message_sent = true;
    }
}
?>
2k adc
  • 9
  • 2

1 Answers1

-1

It's possible using PHP's mail() function. Remember the mail function will not work on a local server.

if you used a local server or lived server?

arun kumar
  • 16
  • 2