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 trialHunter Hawley
3,948 PointsCheck if Form Was Sent in Same File
I am trying to learn how to display a thank you message after a contact form has been submitted on the same page. So if the form is on index.php, and once the form has been submitted it goes to index.php?form_submit=1, how can I make it so that on index.php?form_submit=1 it displays a thank you message by the contact form instead of what is there now, instructions.
1 Answer
Phillip Gibson
13,805 Points<?php if (isset($_GET["form_submit"]) AND $_GET["form_submit"] == 1) { ?>
<p>Thanks for contacting me!</p>
<?php } else { ?>
<form method="post">
<!-- contact form goes here -->
</form>
<?php } ?>
Hunter Hawley
3,948 PointsHunter Hawley
3,948 PointsThanks!
Phillip Gibson
13,805 PointsPhillip Gibson
13,805 PointsGlad to help!