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

Corey Lyons
Corey Lyons
24,684 Points

PHP Quiz question Stage3 Adding a Contact Form

I am stumped on this quiz question. Any help would be appreciated!

The $_GET array contains variables added to the web address. If I want my first name (Randy) displayed by this PHP command ...

echo $_GET["name"];

ā€¦ then what needs to be added to the end of the web address?

http://localhost/contact-thanks.php

2 Answers

Hugo Paz
Hugo Paz
15,622 Points

Hi Corey,

Your URL should look like this:

http://localhost/contact-thanks.php?name=Randy

$_GET is a superglobal in php. A super global is built into php and available all over your script.

$_GET gets populated with information passed through the url in a GET request. The syntax of passing this information through is simply adding a question mark to the end of your url followed by key value pairs.

http://localhost/contact-thanks.php?name=Tom&age=24&food=cheese

You can separate multiple pairs with an ampersand (&).

In the receiving page you can access these values by:

<?php

$_GET['name'] // Tom
$_GET['age'] // 24
$_GET['food'] // cheese