articles

Home / DeveloperSection / Articles / PHP $_Get Function

PHP $_Get Function

Anonymous User8960 09-Sep-2011

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=22Now “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



Updated 07-Sep-2019
I am a content writter !

Leave Comment

Comments

Liked By