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 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.