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 trialJorge Perestrelo
1,055 PointsRedirects to url ?status=thanks but doenst load content.
Hello,
I think everything works fine except the last part, i can see in the browser adress that it redirects but doenst load the content of the page. Can someone help?
Thanks in advance!
Here is my code of contact.php:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'on');
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST["name"];
$email = $_POST["email"];
$message = $_POST["message"];
$emailbody ="";
$emailbody = "$emailbody" . "$name" . "\n";
$emailbody = "$emailbody" . "$email" . "\n";
$emailbody = "$emailbody" . "$message" . "\n";
header("Location: contact?status=thanks");
EXIT;
}
?>
<?php
$pageTitle="Contacto do Site";
$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> THANK YOU!</p>
<?php } else { ?>
<p> Preenche o form pah!</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="email" name="email" id="email">
</td>
</tr>
<tr>
<th>
<label for="message">Mensagem</label>
</th>
<td>
<textarea name="message" id="message"></textarea>
</td>
</tr>
</table>
<input type="submit" value="send">
</form>
</div>
</div>
<?php } ?>
<?php include('inc/footer.php'); ?>
1 Answer
Jeremy Menicucci
19,227 PointsAs best as I can tell from reproducing your code (assuming your include files aren't causing the problem) is the fact that your redirect is missing a file extension.
If that's not case in your code, I'll need to see more.
But essentially change
header("Location: contact?status=thanks");
To
header("Location: contact.php?status=thanks");
Let me know if that fixes it. Once I've changed that, your code is working for me.
Jorge Perestrelo
1,055 PointsJorge Perestrelo
1,055 PointsOFC! It worked, thanks Jeremy!