Results 1 to 6 of 6

Thread: How to use $_GET Function in PHP?

  1. #1
    Join Date
    May 2008
    Posts
    518

    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.

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    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

  3. #3
    Join Date
    May 2008
    Posts
    2,389

    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");
    ?>

  4. #4
    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.

  5. #5
    Join Date
    Oct 2005
    Posts
    2,393

    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

  6. #6
    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;
    }
    ?>

Similar Threads

  1. c# function equivalent to gettime function in javascript
    By Omaar in forum Software Development
    Replies: 4
    Last Post: 10-03-2010, 10:44 PM
  2. Replies: 5
    Last Post: 27-02-2010, 07:52 PM
  3. How does abstract function differs from virtual function?
    By Maddox G in forum Software Development
    Replies: 5
    Last Post: 29-01-2010, 11:32 AM
  4. How to use $_GET in iframes
    By BansiJ in forum Software Development
    Replies: 2
    Last Post: 26-08-2009, 09:54 PM
  5. Function keys don't function under windows XP
    By GunFighter in forum Hardware Peripherals
    Replies: 3
    Last Post: 08-04-2009, 11:07 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,034,610.33156 seconds with 16 queries