passing Vars?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Richard Ragon

    #1

    passing Vars?

    Hows does the passing variables from page to page work?

    Specifically, when you type in a URL like:


    How does the next page get, and use the variable?

    Sorry for the dumb question..

    Thanks

    -Richard


  • Kevin Thorpe

    #2
    Re: passing Vars?

    Richard Ragon wrote:
    [color=blue]
    > Hows does the passing variables from page to page work?
    >
    > Specifically, when you type in a URL like:
    > http://www.someurl.com/test.php?someVar=20
    >
    > How does the next page get, and use the variable?[/color]

    $_GET['someVar'] would be set to 20
    $_POST[] holds values from a POSTed form
    both are merged together in $_REQUEST[]

    .....unless you have an old version of php with register_global s turned
    on in which case:
    $someVar would be set to 20
    ....but I'd try not to use that anymore




    Comment

    • Eric Kincl

      #3
      Re: passing Vars?

      Kevin Thorpe wrote:
      [color=blue]
      > Richard Ragon wrote:
      >[color=green]
      >> Hows does the passing variables from page to page work?
      >>
      >> Specifically, when you type in a URL like:
      >> http://www.someurl.com/test.php?someVar=20
      >>
      >> How does the next page get, and use the variable?[/color]
      >
      > $_GET['someVar'] would be set to 20
      > $_POST[] holds values from a POSTed form
      > both are merged together in $_REQUEST[]
      >
      > ....unless you have an old version of php with register_global s turned
      > on in which case:
      > $someVar would be set to 20
      > ...but I'd try not to use that anymore[/color]

      Also, remember that GET, aka the way you have it (test.php?someV ar=blah),
      isn't the best way of doing things all the time. I find it great for
      specifying the page you want to be on (ie: news.php?page=a rchives), and
      this is how it should be used, but if you are working with form data, I
      would suggest always using the POST method, as it 1. can handle more data,
      and 2. hides the data from the user and makes it harder to spoof.


      -Eric Kincl

      Comment

      • Kevin Thorpe

        #4
        Re: passing Vars?

        Eric Kincl wrote:[color=blue]
        > Kevin Thorpe wrote:
        >
        >[color=green]
        >>Richard Ragon wrote:
        >>
        >>[color=darkred]
        >>>Hows does the passing variables from page to page work?
        >>>
        >>>Specifically , when you type in a URL like:
        >>>http://www.someurl.com/test.php?someVar=20
        >>>
        >>>How does the next page get, and use the variable?[/color]
        >>
        >>$_GET['someVar'] would be set to 20
        >>$_POST[] holds values from a POSTed form
        >>both are merged together in $_REQUEST[]
        >>
        >>....unless you have an old version of php with register_global s turned
        >>on in which case:
        >>$someVar would be set to 20
        >>...but I'd try not to use that anymore[/color]
        >
        >
        > Also, remember that GET, aka the way you have it (test.php?someV ar=blah),
        > isn't the best way of doing things all the time. I find it great for
        > specifying the page you want to be on (ie: news.php?page=a rchives), and
        > this is how it should be used, but if you are working with form data, I
        > would suggest always using the POST method, as it 1. can handle more data,
        > and 2. hides the data from the user and makes it harder to spoof.[/color]

        Basically use GET for navigation and things without side effects.
        Anything which will write to your database should use POST.

        Imagine a page listing every record in your database with a 'delete'
        link next to it. Along comes Googlebot to index your site and merrily
        deletes every record you had. Bots do not (to my knowledge) ever use POST.

        Comment

        Working...