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 trialjason chan
31,009 Pointsisset and _get explain to me how this works?
<?php if (isset($_GET["status"]) AND $_GET["status"] == "thanks") { ?>
<p>Thanks for the email! I’ll be in touch shortly!</p>
<?php } else { ?>
<p>I’d love to hear from you! Complete the form to send me an email.</p>
<form method="post" action="contact.php">
<table>
<tr>
<th>
<label for="name">Name</label>
</th>
<td>
<input type="text" name="name" id="name">
</td>
</tr>
<tr>
<th>
<label for="email">Email</label>
</th>
<td>
<input type="text" name="email" id="email">
</td>
</tr>
<tr>
<th>
<label for="message">Message</label>
</th>
<td>
<textarea name="message" id="message"></textarea>
</td>
</tr>
</table>
<input type="submit" value="Send">
</form>
<?php } ?>
Explain to me plain english what the conditional statement is doing? thanks. Kind of lost.
2 Answers
Eric Buchmann
15,080 PointsIt's checking two different things to check if they're true. But, there's an error with the AND part, that should be &&.
<?php if (isset($_GET["status"]) && $_GET["status"] == "thanks") { ?>
The first part (isset($_GET["status"]) is checking to see if the variable $_GET["status"] is actually declared. The second part is checking if $_GET["status"] is equal to "thanks".
jason chan
31,009 Pointsisset is used to validate if _GET and _POST go through. LOLs.
Ryan Field
Courses Plus Student 21,242 PointsRyan Field
Courses Plus Student 21,242 PointsAs a side note,
AND
isn't incorrect, but it's much less commonly used than&&
.