-1

I am trying to send email from my website form but it keeps on displaying this error Parse error: syntax error, unexpected T_VARIABLE in /home/u892828859/public_html/message.php on line 5

this is my php:

<? php

    // subject and email variables

        $emailSubject = 'message from friend';
        $webMaster    = 'myemail@gmail.com';

    // gathering data variables 

        $emailField = $_POST['email'];
        $subjectField = $_POST['subject'];
        $messageField = $_POST['message'];

        $body = <<<EOD
<br><hr><br>
Email : $email <br>
Subject: $subject <br>
Message : $message <br>
EOD;

    $headers = "from : $email\r\n";
    $headers .="Content=type: text/html\r\n"; /*to let php code to run the html tag as html and rest text*/
    $success = mail($webMaster, $emailSubject, $body, $headers);

    // Result rendered as HTML 

    $theResults = <<<EOD
<html lang="en">

    <head>
        <title><Contact></title>
        <meta charset="utf-8" />
        <link rel ="stylesheet" href="stylec.css" type="text/css" />
        <meta name ="viewport" content="width=device-width, initial-scale=1.0"/>    
    </head>
    <body>
        <p>Your message has been sent </p>
        <a href ="contact.html"  > GO back</a>
</html>
EOD;

echo "$theResults";
?>

and here is my form from my website 


                    <form action="message.php" method="post">
                        Email : </br><input type ="text" name="email"></br>
                        Subject :</br><input type ="text" name ="subject"></br>
                        Message : <br>
                        <textarea rows="10" name ="message" ></textarea>
                        </br>
                        <input type ="submit" value="submit">
                    </form>

can any body tell me what am i doing wrong. thanks

2 Answers2

1

This is pretty simple...

<? php

to

<?php
skrilled
  • 5,350
  • 2
  • 26
  • 48
0

In your very first line there's a space between ? and php. Try removing the space.

Raj
  • 46
  • 2