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
Vincent Bellittera
20,411 PointsHelp with Redirecting after a form submission
When I hit send on my mail form, the contact-process.php page displays with the users information on top of my header?! Tried taking out the <pre> tag around my _POST, but same thing, just displayed the information inline in the same spot. /Thanks for the help/
5 Answers
Vincent Bellittera
20,411 Points<pre> <?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;
?> </pre> <?php
// TODO: Send Email
$pageTitle = "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"); ?>
Vincent Bellittera
20,411 PointsSorry I don't think I posted it correctly. Let me know if you need me to post it differently.
Thanks Jason!
Jason Anello
Courses Plus Student 94,610 PointsHere's a post with tips on how to post code for future reference:
https://teamtreehouse.com/forum/how-to-type-code-in-the-forum
Jason Anello
Courses Plus Student 94,610 PointsHi Vincent,
After building up the $email_body variable you are then echoing it to the page with echo $email_body; This is being output to the page which it shouldn't be.
Jason Anello
Courses Plus Student 94,610 PointsAlso, you don't have to close and then reopen a php tag right before the comment reminder to send the email later. All of the upper part of that page is php code and so it can be within a single php tag.
Check the video again around 2:26 and compare your code with the instructor's.
Vincent Bellittera
20,411 PointsOkay great, I guess that makes a lot of sense! Thanks for the help, I really appreciate how quick you responded. Vince
Vincent Bellittera
20,411 PointsIt worked! Thanks again Jason!!
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsCan you post your code?