PHP Tutorial – $_GET Function

The PHP built-in $_GET function is used to collect values in a form (as name says, you do this with the method=”get”) You should remember that the information sent from a form with the GET method is visible to everyone, because the result is displayed in the address bar.

The $_GET function limits the number of characters to be send (max. 100 characters.)

An example:


<html>
<body>

<form action="test.php" method="get">
Your name: <input type="text" name="yourname" />
<input type="submit" />
</form>

</body>
</html>

When the user clicks on submit, an URL is sent to the server that will look something like this:



http://www.codingunit.com/test.php?yourname=John

Warning: as you can see you can read the input text. That’s why you should be careful with $_GET function. For example you should never use a GET method in a login form.

But it can also be useful to see what the content is of the variable. Because the variables are displayed in the URL, you can for example bookmark the page. Just an example, but you should be careful with the get method.

This entry was posted in PHP Tutorials. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed. Tweet This! Tweet This! or use to share this post with others.

There is currently one response to “PHP Tutorial – $_GET Function”

Why not let us know what you think by adding your own comment!

  1. Sweet hazarika on March 10th, 2014:

    Sir i am trying to retrieve data from mysql table using php get method my database name is sweet and my table name is person so sir i am not able to get the data from my mysql database pls can you assist me