Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



How to use $_GET Function in PHP?

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 02-02-2010
Member
 
Join Date: May 2008
Posts: 515
How to use $_GET Function in PHP?
  

I have done basic programs in PHP. I am making a form in PHP, in which I have used the method="get". Now I want to collect the values from that form which is having the get method. I know that we use the $_GET Function for collecting the values. But the thing is that I don't know how to use $_GET Function in PHP? Hope that someone will help me sooner.!! Also if possible provide me the sample of coding, so that it will make me easy to understand.

Reply With Quote
  #2  
Old 02-02-2010
Member
 
Join Date: Feb 2008
Posts: 1,848
Re: How to use $_GET Function in PHP?

Its right that if you are having the method="get", then you can use the built-in $_GET function to collect the values in a form. The drawback of using the GET method in a form is that the information is visible to everyone which gets displayed in the browser's address bar. And the second drawback is that it has limits on the amount of information to send which is the 100 characters. The following is an example of the get method :
PHP Code:
<form action="introduction.php" method="get">
Name: <input type="text" name="name" />
Age: <input type="text" name="place" />
<
input type="submit" />
</
form
Reply With Quote
  #3  
Old 03-02-2010
Member
 
Join Date: May 2008
Posts: 2,383
Re: How to use $_GET Function in PHP?

I think that looking at the code will make you understand more properly. I have given the index.php, which you can try in your module :
PHP Code:
<?php
if (!eregi("modules.php"$_SERVER['PHP_SELF'])) {
    die (
"You don't have right to access this file");
}
$index 0;
require_once(
"impfile.php");
$module_name basename(dirname(__FILE__));
include(
"headers.php");
$emb $_GET['vid'];
OpenTable();
?>

      <EMBED type='application/mplayer2'
        pluginspage='http://microsoft.com/windows/mediaplayer/en/download/'
        id='mediaPlayer' name='mediaPlayer'
        bgcolor='darkred' showcontrols="true"
        showdisplay='0' showstatusbar='-2' width="410" height="325"
        src="<?php echo "$emb"?>" autostart="true" designtimesp='5311' loop="false">
      </EMBED>

<?php
CloseTable
();
include(
"footers.php");
?>
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
  #4  
Old 03-02-2010
Member
 
Join Date: Nov 2005
Posts: 1,323
Re: How to use $_GET Function in PHP?

When you are using the method="get" in your form, you should know that the all variable names and values are displayed in the URL, which is the major drawback of the method="get". You should keep in mind that this method should not be used when sending passwords or other sensitive information. In some cases it can be useful to bookmark the page because the variables are displayed in the URL. Also the another drawback of that is the get method is not suitable for large variable values; the value cannot exceed 100 characters. So I would suggest you to use the method="post" in your form. You should also know that in PHP, every file that includes mainfile.php and runs its own must be placed in the phpNuke root.
Reply With Quote
  #5  
Old 03-02-2010
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: How to use $_GET Function in PHP?

The get method also passes an associative array of variables passed to the current script via the URL parameters. The $HTTP_GET_VARS is an example of that. That variable contains the same initial information. The following is an example of $_GET :
PHP Code:
<?php
echo 'Hi Everyone ' htmlspecialchars($_GET["greet"]) . '!';
?>
Let us assume that the user entered http://example.com/?greet=Dyenker
Then the above example will output something similar to :
Code:
Hi Everyone Dyenker
Reply With Quote
  #6  
Old 03-02-2010
Member
 
Join Date: Apr 2008
Posts: 1,948
Re: How to use $_GET Function in PHP?

I would like to tell you that for accessing the variable within functions or methods, there is no need to do global $variable. You can also use the $_GET with Switch Statement in PHP..!! The following code demonstrates the same :
PHP Code:
<?php
switch ($_GET["type"])
{
case 
"silver":
require ( 
"file1.php" );
break;
case 
"gold":
require ( 
"file2.php" );
break;
case 
"diamond":
require ( 
"file3.php" );
break;
case 
"platinum":
require ( 
"file4.php" );
break;
}
?>
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to use $_GET Function in PHP?"
Thread Thread Starter Forum Replies Last Post
c# function equivalent to gettime function in javascript Omaar Software Development 4 10-03-2010 10:44 PM
How to pass function with parameters to another function in PHP? Linoo Software Development 5 27-02-2010 07:52 PM
How does abstract function differs from virtual function? Maddox G Software Development 5 29-01-2010 11:32 AM
How to use $_GET in iframes BansiJ Software Development 2 26-08-2009 09:54 PM
Function keys don't function under windows XP GunFighter Hardware Peripherals 3 08-04-2009 11:07 PM


All times are GMT +5.5. The time now is 12:37 AM.