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

Nthulane Makgato
Courses Plus Student 19,602 PointsAdding forms.
Hi Guys,
I'm following along with the videos on the php track and we are creating a form. I understand what is going on but my contact page won't show. Please let me know what is wrong:
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$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");
exit;
}
?><?php
$pageTitle = "Contact Mike";
$section = "contact";
include('inc/header.php');
?>
<div class="section page">
<div class ="wrapper">
<h1>Contact</h1>
<?php if (isset($_GET["status"]) AND ($_GET["status"] == "thanks") { ?>
<p>Thanks for the email! I’ll be in touch shortly.</p>
<?php } else { ?>
<p>I’d love from you! Complete the form to send me an email.</p>
<form method="post" action="contact.php">
<table>
<tr>
<th>
<label for="name">Name</label>
</th>
<td>
<input type="text" name="name" id="name">
</td>
</tr>
<tr>
<th>
<label for="email">Email</label>
</th>
<td>
<input type="text" name="email" id="email">
</td>
</tr>
<tr>
<th>
<label for="message">Message</label>
</th>
<td>
<textarea name="message" id="message"></textarea>
</td>
</tr>
</table>
<input type="submit" value="send">
</form>
<?php } ?>
</div>
</div>
<?php include('inc/footer.php'); ?>
Please help.
2 Answers

dhillonsh
4,745 PointsI believe I see the problem; replace where you have:
<?php if (isset($_GET["status"]) AND ($_GET["status"] == "thanks") { ?>
with:
<?php if (isset($_GET["status"]) AND $_GET["status"] == "thanks") { ?>
You added an extra ( before the $_GET["status"] which created a syntax error in the php code, preventing it from loading.

Nthulane Makgato
Courses Plus Student 19,602 Points@Alejandro Cavazos, I will try it. Thank you.
I have errors with my php and I have your lines of code in my code. Please detail how i'm supposed to use it as nothing is happening.
Alejandro Cavazos
4,250 PointsAlejandro Cavazos
4,250 PointsSave yourself some time and add this two lines of code to the top of your php
It will display errors and let you know whats going on.
IMPORTANT: Remove this two lines when pushing to production