$_GET[] Simple Usage and Brief Description

$_GET[] is a PHP function. Mostly PHP Personal Functions starts from underscore "_".
$_GET[] is used to get value from other file. Example is shows bellow

I created 1st file with name : form.html


 <form action="index.php" method="get"> <!--Action is used to sand data to "index.php" file-->  
 <!--  
 ##################################################  
 # Table is used to align data with certain order #  
 ##################################################  
 -->  
 <table>  
 <tr><td><label for="FName">Type Your 1st Name:</label></td><td><input type="text" name="FName" placeholder="Type 1st Name" /></td></tr> <!--name attribute is used to get value at index.php-->  
 <tr><td><label for="LName">Type Your 1st Name:</label></td><td><input type="text" name="LName" placeholder="Type Last Name" /></td></tr> <!--placeholder is used to show guidance -->  
 <tr><td><label for="Number">Type Your 1st Name:</label></td><td><input type="text" name="Number" placeholder="Type your number" maxlength="10" /></td></tr>  
 <tr><td>&nbsp;</td><td align="left"><input type="submit" value="submit" /></td></tr> <!--&nbsp; is used to add spance-->  
 </table>  
 </form>  

Note : form.html was separate file and data is sent to index.php
Now I created 2nd file with name : index.php


 <?php   
      $fname = $_GET[FName]; // Here I got 1st name data   
      $lname = $_GET[LName]; # Here I got Last name data  
      $number = $_GET[Number]; /* Here I got number data */  
      //---------------------------------------------------------//  
      // I used different Comments styles above to remind them  //  
      // I used different Variables styles bellow to remind them //  
      //---------------------------------------------------------//  
      echo "User First Name is : {$fname} <br />"; # Variable with curly brackets within double qoutes  
      echo "User Last Name is : $lname <br />"; # Variable without curly brackets within double qoutes  
      echo "User Number is : " . $number # Variable with dot operator  
 ?>  


Here I got URL as :

http://www.qwc.me/index.php?FName=Samee+Ullah&LName=Feroz&Number=3234223945

Now try to understand this line

FName=Samee+Ullah&LName=Feroz&Number=3234223945 

Here you need to understand 3 things
after URL :
  1. http://www.qwc.me/index.php = URL Main Part
  2. ?  = Question Mark
  3.  FName=Samee+Ullah = Value

this value is sent to index.php

Post a Comment

Give your reviews about this blog. Leave your comments. What do you think about this post?

Comments Guidelines:

1) I love to read comments, but please avoid spam.

2) Like this blog, share your insights, and spread the word.

3) You can use basic HTML/xHTML tags.

4) All comments are DoFollow—please use the section professionally.

5) Kindly mention your name or brand below your comment.

6) Constructive suggestions for improvement are always welcome.


Thanks for visiting Samee Articles.

========================================

Best Regards,

Samee U. Feroz

 
Copyright © 2011-2026. Samee Articles - All Rights Reserved
Proudly powered by Blogger