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 Checking the Request Method

Ivan Ivetic
Ivan Ivetic
6,508 Points

Can somebody explain to me what is the purpose of $_SERVER var and checking if REQUEST_METHOD = POST?

And one more thing... in this concrete lesson,its stupid that when you dont fill inputs you still get notification: Thanks for the mail...

Hey Ivan,

$_SERVER is a superglobal variable in PHP--superglobals are variables that are built in and they are not restricted by variable scope. $_SERVER is an array of available information about how the server parsing PHP is configured. If you are interested in it there's info about it here: http://php.net/manual/en/reserved.variables.server.php. In practice, it may help to insert:

<? php var_dump($_SERVER); ?>

$_REQUEST is also a superglobal associative array that holds information from get, post, and cookie. GET will append information to the end of a URL, POST will send info to a URL. POST is good for private information.

In regards to your comment about inputs, later in the course you will cover how to check for empty inputs. You need an if statement that says: IF(!empty(input)) {send notification}.

Good luck. Hope this helps!

1 Answer

Hello Stephen,

I am sorry for not responding to your message. There is something wrong with my account; I am getting some messages and not others.

Let me repost this message, hopefully the vote feature appears.

I also have so me questions.