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

Chase Lee
29,275 PointsRedirecting After a Form Submission
Hi,
I am doing "Redirecting After a Form Submission" in "Build a Simple PHP Application", and got to the part where Randy has us take the users to the "contact-thanks.php
". But it dosen't work for me.
Here is the code I have in contact-process.php
:
<?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;
//TODO: Send Email
header("Location: contact-thanks.php");
?>
Here is contact-thanks.php
:
<?php
$page_title = "Contact Mike";
$section = "contact";
include("inc/header.php"); ?>
<div class="section_page">
<div class="wrapper">
<h1>Contact</h1>
<p>Thanks for the email. I’ll be in touch shortly.</p>
</div>
</div>
<?php include("inc/footer.php"); ?>
And here is a link to my layout.
Thanks.
2 Answers

Chase Lee
29,275 PointsFigured it out. Had to take out the echo command.

adrie silva
6,416 PointsThis question is for Randy,
If I'm placing my contact form in an iframe, or using an iframe, the function header () won't work, what do you suggest?
Thanks!
Randy Hoyt
Treehouse Guest TeacherRandy Hoyt
Treehouse Guest TeacherYep. Once anything gets echo'd out or displayed to the screen, it is too late to set headers. Glad you got it working!
adrie silva
6,416 Pointsadrie silva
6,416 PointsHi I have a question about redirecting contact forms.