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 trialPeter Garside
7,233 PointsUnexpected Result
I have come to the end of this exercise and I seem to be missing something because I have been unable to produce the desired result. The contact form simply resets after submission instead of send forwarding to the thank you message.
(I am running this on a local mamp service and viewing through Chrome on a Mac OS X 10.9.2)
<?php if (isset ($_GET["status"]) AND $_GET["status"] == "thanks"); { ?>
<p>Thanks for the email! I'll be in touch shortly.</p>
<?php } else { ?>
<p>...</p>
<form method="post" action="contact.php">...</form>
I have also attempted (after advice from elsewhere) to change AND to &&, as below(but also to no avail);
<?php if (isset ($_GET["status"]) && $_GET["status"] == "thanks"); { ?>
I am a bit stumped and would greatly appreciate any pointers as where I am going wrong.
Many thanks,
Peter
2 Answers
Jason Anello
Courses Plus Student 94,610 PointsHi Peter,
You have a semi-colon at the end of your if
conditional.
Post back here if there are still problems after fixing that.
Peter Garside
7,233 PointsThank you so much for the response Jason :)
Indeed I did, thanks for that, I've corrected this and double checked all of my code to make sure I haven't done this elsewhere also.
But unfortunately the same problem persists....
EDIT: I've now found the problem, slightly embarrassing :) Not related to the code snippet I posted at all. I had left the underscore out of $_SERVER, see below;
if ($SERVER["REQUEST_METHOD"] == "POST") {
Should have been...
if ($_SERVER["REQUEST_METHOD"] == "POST") {
Anyway, thanks for the help Jason.
Peter