$_get

Discussion in 'PHP' started by harry1, Aug 26, 2009.

  1. #1
    what is the working of this line
    'http://localhost/movies/moviesite.php?fm=$fm
    why we have to post the variable like this
    what is the benefits and disadvantage of of this style of coding ?
     
    harry1, Aug 26, 2009 IP
  2. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #2
    Well the main reason we use such a thing is that we can easily give users a chance to remember or bookmark the url
     
    Bohra, Aug 26, 2009 IP
  3. kblessinggr

    kblessinggr Peon

    Messages:
    539
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #3
    That and you can easily go back and forth in a browser without it constantly asking you if you want to re-send data. It's also the main way to pass data from an html link (ie: you can't POST from a link in an email for example).
     
    kblessinggr, Aug 26, 2009 IP
  4. GNetCoder

    GNetCoder Peon

    Messages:
    68
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    A $_GET variable is a quick and easy way to pass variables from one page to the next.

    For example, say you had a form on index.php where a user can choose a movie format. The form takes the user input and sends the results to moviesite.php

    If they choose 'avi', then the form (assuming it has action=moviesite.php, method=get, and an input name=fm, value=avi) when submitted the form will send the user to moviesite.php?fm=avi.

    Then, on moviesite.php, you can add:

    $movie_format = $_GET['fm'];

    Then the user's input is stored in $movie_format, and you can use that for whatever your need is.
     
    GNetCoder, Aug 26, 2009 IP
  5. kane4545

    kane4545 Guest

    Messages:
    99
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    When you want to pass variables with query string then its useful it will find on which link you have clicked
     
    kane4545, Aug 26, 2009 IP