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 trialZander Fields
Courses Plus Student 5,458 PointsRedirect doesn't seem to work
Hello, I've got my code looking exactly like what Randy has in his tutorial, but I can't seem to get the redirect to occur. Does anyone else have this issue?
3 Answers
Eric Martz
16,007 PointsCan you post your code so we can see it?
Zander Fields
Courses Plus Student 5,458 PointsSure! Here's my contact-process:
<?php
$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;
echo $email_body;
header("Location: contact-thanks.php");
?>
Also, here's my contact.php page
<?php
$pageTitle = "Contact Mike";
$section = "contact";
include('inc/header.php'); ?>
<div class="section page">
<div class="wrapper">
<h1>Contact</h1>
<p>I’d love to hear from you! Complete the form to send me an email.</p>
<form method="post" action="contact-process.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">E-mail</label>
</th>
<td>
<input type="text" name="email" id="email">
</td>
</tr>
<tr>
<th>
<label for="message">Message</label>
</th>
<td>
<textarea type="text" name="message" id="message"></textarea>
</td>
</tr>
</table>
<input type="submit" value="Send">
</form>
</div>
</div>
<?php include('inc/footer.php'); ?>
Zander Fields
Courses Plus Student 5,458 PointsJust found the answer: I was echoing $email_body, which you can't do with a header() function. Thanks for looking into it though Eric!