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

PHP Build a Basic PHP Website (2018) Adding a Basic Form Checking the Request Method

Teo Manetti
Teo Manetti
7,411 Points

Why the $mail_body has not been ECHOed by the file?

Just wondering why even though we are redirected from "suggest.php" to "suggest.php?status=thanks" the echo $mail_body inside the conditional doesn't work, showing its content In the previous video we were redirected to "thanks.php", so it was obvious we couldn't see the form's content but now what's blocking the echo $mail_body from showing into the page its content?

Matt Corby
Matt Corby
2,385 Points

I don't understand why her $email_body isn't echoed to the page either... it does on mine. I had to comment it out.

1 Answer

Matt Corby
Matt Corby
2,385 Points

I figured it out!

So the reason why the information in $email_body doesn't appear is because she used a header function to redirect to the same page with a GET variable, which will make the page appear differently as long as you have a conditional checking for the variable.

The redirection looks like this:

header("location:suggest.php?status=thanks");

and the conditional looks like this

<?php if(isset($_GET['status'] && $_GET['status'] == "thanks"){ echo "<p>Thank you</p>"; } else { ?>

HTML Form Stuff

<?php } ?>

Since she redirected none of the $email_body data appears.

Teo Manetti
Teo Manetti
7,411 Points

Oh yeah right thank you! I almost forgot about that :/