PHP GET Variable

PHP GET variable tutorial will explain you How does $_GET variable works in PHP? With examples.

PHP GET method sends its variables through web browsers URL, which makes it visible and possibly change the information that was sent.

PHP GET method should not be used when sending passwords or other sensitive information. It also should not be used for any actions that cause a change in the server, such as placing an order or updating a database.

PHP GET Variable

When working with PHP GET method we can collect all form variables with the PHP $_GET variable (which is in array format).

Using PHP GET method all the submitted information is displayed in the address bar as part of the URL. Information is followed after question mark “?” (Called a query string), something like:
http://domain.com/script.php?name1=value1&name2=value2

Example on PHP GET Variable

myform.html:

collect.php

When user clicks submit button, it will look like this in address bar on the browser.
http://www.somesite.com/collect.php?name=steve&email= steve@gmail.com

Output will be:

When to use GET method in PHP

The PHP GET method has a limit on the amount of information than can be sent. This can be useful for example where you want to be able to bookmark a page with specific query string values.

We also don’t want to use PHP GET method when submitting sensitive information like passwords or credit card details as they would show up in the address bar.

SHARE
Previous articleHTML Form in PHP
Next articlePHP POST Variables
I am a young Information Systems Security Engineer(CEH). I had started with penetration testing when i am 17 years old. It all started with Kali linux and Metasploit.In free time i will play with Security holes/Bug bounty/Pentesting and Hacking !!!