PHP $_GET Tutorial

The GET method is simply a way of passing data to a server. In this tutorial we will help you to get familiar with retrieving data (which was sent via HTML forms) using PHP.

When data is sent using an HTML form to the server, PHP will intercept this data and create an array which holds all the data.

When the GET method is used to send the data, PHP will store the data in the superglobal $_GET associative array. If we want to retrieve the data, we would have to retrieve it from the array as described in our PHP array tutorial.

PHP $_GET Syntax

Retrieving some data passed using the GET method is fairly simple.:

$variable = $_GET['parameter'];

That's all there is to retrieving data passed to a script using the get method.

PHP $_GET Example

Suppose this form was sent:

<form action="" method="get">
Name: <input type="text" name="name" />
School: <input type="text" name="school" />
<input type="submit" />

The URL it would go to is:

If we had a script at that location we would be able to retrieve the values using:

$name = $_GET['name'];
$school = $_GET['school'];

Once we had the variables we would be able to work on them as we desired.

Link to this Page

Thank Tutorial Arena for This Tutorial.
Show your appreciation with a +1...