Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP Build a Simple PHP Application Adding a Contact Form Working with Get Variables

Jonathan Fernandes
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




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,135 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!