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 Simple PHP Application Adding a Contact Form Working with Get Variables

Jonathan Fernandes
PLUS
Jonathan Fernandes
Courses Plus Student 22,784 Points

What's the point of the added conditional statement?

So, in the condition, he has it check to make sure that both

isset($_GET["status"])

and

$_GET["status"]

are equal to "status". What is the point of the first part of this condition. As far as my code is concerned, it runs just fine with just the second condition. So what does the isset method do?

1 Answer

Kevin Korte
Kevin Korte
28,149 Points

He states the reason starting at 2:53 of the working with variables video.

The second statement simply checks the value of the status variable. But if that variable hasn't been set yet, than you can get an error that would show up on the client browser.

The isset function checks if the variable has even been set, or given a value. Basically, we first check to see if the status variable has a value, and if it does, is it set to "thanks". It's a two step process but it's more robust.

Whenever you're retrieving values from forms and attaching them to a variable, you need to check if the variable is set first.

Jonathan Fernandes
Jonathan Fernandes
Courses Plus Student 22,784 Points

Thanks Kevin! That makes sense! Thanks so much for the speedy reply!