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 trial
Le Var Range
Front End Web Development Techdegree Student 18,011 PointsGet Variable php shirt project.
I would like to know why the get variable ("thanks" ) is not showing up on my browser... i did everything the tutorial had mentioned.. my own code worked up until i applied the isset() function to my $_GET variable... now when i click the send button .... just a clear white page shows up... no error is displayed .. and i dont see the variable i am suppose to see after the contact.php ... i dont see the following variable "thanks" at the end of the url... can u please tell me what I am doing 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;
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 to hear 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"); ?>
ixrevo
32,051 PointsIf you see a white screen of death in php, you should consider to check error reporting options in your php.ini file
error_reporting E_ALL
display_errors 1
http://uk3.php.net/manual/en/errorfunc.configuration.php#ini.error-reporting
3 Answers
Tunde Adegoroye
20,597 PointsPut a slash infront of contact so it's
header("Location: \contact.php?status=thanks");
Jason Anello
Courses Plus Student 94,610 PointsHi Le Var Range ,
It seems like your header redirect isn't working. This could happen if you have any output to the page before header.
Is your opening php block <?php the 1st line of your file?
Make sure that you don't have any blank lines or any kind of whitespace before that.
Le Var Range
Front End Web Development Techdegree Student 18,011 PointsThank you so much for you guys suggestions .. i did figure it out it was a whitespace issue.
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsCan you post the code you have for that?