Home > DeveloperSection > Articles > PHP $_Get Function

PHP $_Get Function


PHP PHP 
Ratings:
0 Comment(s)
 4946  View(s)
Rate this:

PHP $_Get Function

In this article I will be described, how to use $_Get function in PHP. In PHP, two function are available $_Get () and $_Post () for passing values from one page to another page, this functions are used to get the values which are passed from a user-filled form (User input value form), like user registration or login form etc.

Now here I will be discussed on $_Get function and how to implement in PHP.

The built-in $_GET function is used to collect values from a form sent with method="get". Information sent from a form with the GET method is visible to everyone (it will be displayed in URL) and has limits amount of information to send.

 Let’s we have an example, how to use $_Get function in PHP.

Example:

<html>

  <head>

       <title> Get Methods</title>

  </head>

  <body>

              <form action="GetMethod.php" method="GET">

              <table>

              <tr>

              <td>Name: </td>

              <td><input type="text"  name ="uname"/>

              <td>

              </tr>

              <tr>

                           <td>Age : </td>

                            <td><input type="text"  name="age"/> </td>

              </tr>

                     <tr>

                     <td></td>

              <td><input type="submit"  value="Submit"/> </td>

              </tr>

              </table>

              </form>

  </body>

</html>

Now when user click on ‘Submit’ button, the URL send to the server will look like this:

http://localhost:85/MySiteFile/GetMethod.php?uname=Arun++Kumar+Singh&age=22

Now “GetMethod.php” form used $_GET() function to collect form data.

“GetMethod.php” file contains the following code.

<html>

  <head>

       <title> Get Methods</title>

      

  </head>

  <body>

       <?php

                echo "Welcome :".$_GET['uname']."</br>";

                echo "you are ". $_GET['age']."years old";

        ?>   

  </body>

</html>

Now the output will be:

PHP $_Get Function

When you click on ‘Submit’ button then ‘GetMethod.php’ will be showing as:

PHP $_Get Function


Don't want to miss updates? Please click the below button!

Follow MindStick