Download this Blogger Template by Clicking Here!

Ad 468 X 60

Friday, 22 March 2013

Widgets

Php Tutorial - $ Get Method

$_GET Method Php Tutorial :



$_GET Method Php Tutorial :
$_GET Method Php Tutorial :


I am sure that you have now properly understood and got the Introduction of SuperGlobal Arrays In php, as we have discussed it in our previous posts. $_GET method is one of the SuperGlobal Arrays which is very important concept in php. Here in this post we are going to learn Get Method in depth and briefly, so that you can understand it well. You can also check $_POST method tutorial.

What is $_GET Method ?


$_GET is also a superglobal array which is based on querystrings that are sent with the URL. You may have already seen many querystrings in web addresses of different sites. For example

http://www.example.com/search.php?keyword=pakistan

You can see in this example that along with URL a Querystring is also sent along with the URL.  In the Querystring , there is a question mark ? after the name of the page in URL.

One URL can have more than one Querystrings. Like

http://www.example.com/search.php?keyword=pakistan&city=isb

In the above URL, we have two Querystrings. One is keyword and the second is city. Both these Querystrings are connected with & symbol. For getting the value of such a Querystring, we use $_GET method.

Let us understand it using an example

Make a new folder in c:/xampp/htdocs and rename the new folder with name as get. Now open your php text editor and open a new file in it. Put the code in it which is given below and save this file in c:/xampp/htdocs/get as link.php.


(link.php)

<HTML>
<HEAD>
<TITLE> Using Get Method </TITLE>
</HEAD>
<BODY>
<a href=”get.php?site=MyTricksLab”> Sending Querystring </a>
</BODY>
</HTML>

Save this file. Now open a new file In php editor and put the following code in it and save this file in C:/xampp/htdocs/get with name get.php

(get.php)

<HTML>
<HEAD>
<TITLE> Get Querystring Data </TITLE>
</HEAD>
<BODY>
<?php
/* Now We will get the Querystring Data by using $_GET array */
$siteName = $_GET[‘site’];Print “ Welcome To “.$.siteName ;
?>
</BODY>
</HTML>

Save this file and open it in in your web browser by typing this address
http://localhost/get/link.php and then press enter.Make sure before typing this address, that you have properly installed and configured Xampp and php tools. Now a link will come on page that we have made using href tag. When you will click on this link then this message will appear on screen

Welcome To MyTricksLab

After clicking the link, check the address bar in the browser. You will see a link just like this

http://localhost/get/get.php?site=MyTricksLab

In this URL, site is a Querystring whose value is MyTricksLab. We are getting this value from another page get.php using $_GET  array. If we are using get in the method of the form then the data of fields of form will automatically become a Querystring and will become the part of URL and we can get this by using $_GET array method.


Php Tutorial Get Method In Urdu :


Php Tutorial Get Method In Urdu :
Php Tutorial Get Method In Urdu :



SHARE THIS POST   

  • Facebook
  • Twitter
  • Myspace
  • Google Buzz
  • Reddit
  • Stumnleupon
  • Delicious
  • Digg
  • Technorati
Author: Mohammad
Mohammad is the founder of STC Network which offers Web Services and Online Business Solutions to clients around the globe. Read More →

1 comment: