Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Build a Simple PHP Application Adding a Contact Form Working with Get Variables

I'm getting a "Parse Error": syntax error, unexpected '<' in my code.

Here's my code:


    $name = $_POST["name"];
    $email = $_POST["email"];
    $message = $_POST["message"];
    $email_body = "";
    $email_body = $email_body . "Name: " . $name . "\n";
    $email_body = $email_body . "Email: " . $email . "\n";
    $email_body = $email_body . "Message: " . $message;

    // TODO: Send Email

    header("Location: contact.php?status=thanks");
$pageTitle = "Contact Mike";
$section = "contact";
include('inc/header.php'); ?>

    <div class="section page">

        <div class="wrapper">


            <?php if (isset($_GET["status"]) AND $_GET["status"] == "thanks") { ?>
                <p>Thanks for the email! I&rsquo;ll be in touch shortly.</p>
            <?php } else { ?>

                <p>I&rsquo;d love to hear from you! Complete the form to send me an email.</p>

                <form method="post" action="contact.php">

                                <label for="name">Name</label> 
                                <input type="text" name="name" id="name">
                                <label for="email">Email</label> 
                                <input type="text" name="email" id="email">
                                <label for="message">Message</label> 
                                <textarea name="message" id="message"></textarea>
                    <input type="submit" value="Send">


            <?php }



<?php include('inc/footer.php'); ?>

I cannot locate this "syntax error" anywhere. Help!

1 Answer

Looks like down toward the bottom there is a opening php but not a closing php before the HTML starts again. <?php }

Yes that's it! Also with that error, did it not also give you the line number that error ocurred on?