PHP Form get

The $_GET variable is used to receive the form information sent by the form method = "get".


$_GET variable data structure with $_POST similar, but also an associative array, the key name for the form element name, used to collect HTTP GET request data.

Form form.php:

<form name = "commentform" method = "get" action = "comment.php">
Salutation: <input type = "text" name = "nickname" />
<input type = "submit" value = "Submit" />

The previous example form to GET mode, enter the address, the browser address bar, looks similar to the following(IE browser may be encoded by encode):

Get GET form data:

echo 'Your name is : ' . $_GET["nickname"];
// Output: Your name is : john


  1. GET method will form data exposed in the browser address bar, it is not appropriate to send sensitive data(such as passwords, etc.), sensitive information sent using POST mode.
  2. The GET method has some restrictions on the amount of information sent. if you send large messages, use the POST method.
  3. GET pages can be accessed by adding a favorite in the future can be directly accessed, and POST mode to access the page can not.


The HTTP GET method is used not only for form data transmission, but also for a more general way of obtaining the information of the resource specified by the request URL(browser address).

Using HTTP GET method can also be passed to the Web page data, such as the following address:

In this example, a message with id = 10 is passed to article.php via the address GET method. In article.php can be achieved through $_GET["id"] data, the actual role may be read from the database id 10 of this article, a number of data to connect with the ampersand:

Get the GET data in article.php:

echo $_GET["type"]; // Output 2
echo $_GET["id"]; // output 10


The $_REQUEST variable is also predefined in PHP, which contains $_POST, $_GET, and $_COOKIE. Its access with $_POST, etc.:

echo $_REQUEST["nickname"] // Output the user-entered title
echo $_REQUEST["id"]; // output 10

Copyright 2014-2017 by All Rights Reserved.