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! While you're at it, check out some resources Treehouse students have shared here.
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 trialSiraj Khan
3,451 PointsWhats wrong with my code for the lesson "Checking the Request Method".??
PHP
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST["name"];
$email = $_POST["email"];
$details = $_POST["details"];
echo "<pre>";
$email_body = "";
$email_body .= "Name " . $name . "\n";
$email_body .= "Email " . $email . "\n";
$email_body .= "Details " . $details . "\n";
echo $email_body;
echo "</pre>";
// TO DO: Send email
header("location:suggest.php?status=thanks");
}
$pageTitle = "Suggest a media Item";
$section = "suggest";
include('inc/header.php'); ?>
<div class="section page">
<div class="wrapper">
<h1>Suggest a Media Item</h1>
<?php if (isset($_GET["status"]) && $_GET["status"] == "thanks"] {
echo "<p>Thanks for the email. I will check out your suggestion shortly!</p>";
} else { ?>
<p>If you think there is something I am missing, let me know.! Complete the form to send me an email.</p>
<form method="post" action="suggest.php?status=thanks">
<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="details">Suggest Item Details</label></th>
<td><textarea name="details" id="details"></textarea></td>
</tr>
</table>
<input type="submit" value="Send"></input>
</form>
<?php } ?>
</div>
</div>
<?php include('inc/footer.php'); ?>
1 Answer
Niki Molnar
25,698 PointsJust a quick look but it seems like the line under your H1 header of Suggest a Media Item says:
if (isset($_GET["status"]) && $_GET["status"] == "thanks"] {
You're not closing the if() bracket at the end before the opening parenthesis, as in:
if (isset($_GET["status"]) && $_GET["status"] == "thanks"]) {
Hope that helps!
Niki