![]() |
|
PHP $_GET variable. Free online PHP and MySQL Web Database Programming Tutorial... |
| Lessons | PHP $_GET Variable |
|
|
In other words the $_GET variable is an array of variable names and values sent by the HTTP GET method. Please remember that the information sent from a form with the GET method is visible to everyone i.e. it is displayed in the browser's address bar and it also has limits on the amount of information to send. Example <form action="phpGET.php" method="get"> Name: <input type="text" name="name" /><br> Occupation: <input type="text" name="occ" /><br> <input type="submit" /> </form><br> OUTPUT When you click the "Submit" button, the internet browser would take you to a URL looking something like: http://www.pickatutorial.com/phpGET.php?name=abc&occ=xyz The "phpGET.php" file can now use the $_GET variable to catch the form data as shown below (notice that the names of the form fields will automatically be the ID keys in the $_GET array): $name = $_GET["name"]; $occupation = $_GET["occ"]; Be careful when using the html form method "get", as all variable names and values are displayed in the URL. So this method should not be used when sending passwords or other sensitive information to the server! The HTTP GET method is also not suitable on large variable values, as there is a limit on the length of a URL.
Next: PHP $_post
|