Can't unset $_GET

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Georg Weiler

    #1

    Can't unset $_GET

    Hi,

    I'm biting my nails on this for several days now, hope that someone of
    you can help me...:

    On my page, the user can display tables, created out of a database. So I
    have several <a href> links to display the various tables. They all look
    something like:

    <a href=this_page. php?table=mytab le1>the first table</a>
    <a href=this_page. php?table=mytab le2>the second table</a>
    <a href=this_page. php?table=mytab le3>the third table</a>

    etc.

    so the user clicks on a link and gets the table. now, when he goes back
    to the main page, and chooses another link, he always returns to the
    initial table, because the $table variable is still somehow "active"

    I tried to unset the $_GET array at the start of the code of the main
    page, but still it does not work. When i do a print_r($_GET) before and
    after the unset, it shows me that in the $_GET array exists before the
    unset, but is away after the unset, so everything should be fine.

    But why does the $table variable still remain in the system?!?

    Please help, I'm totally stuck!!!

    thanks a lot,
    georg.
  • Peter Fox

    #2
    Re: Can't unset $_GET

    (un)register globals
    --
    PETER FOX Not the same since the borehole business dried up
    peterfox@eminen t.demon.co.uk.n ot.this.bit.no. html
    2 Tees Close, Witham, Essex.
    Gravity beer in Essex <http://www.eminent.dem on.co.uk>

    Comment

    • Gordon Burditt

      #3
      Re: Can't unset $_GET

      >I'm biting my nails on this for several days now, hope that someone of[color=blue]
      >you can help me...:
      >
      >On my page, the user can display tables, created out of a database. So I
      >have several <a href> links to display the various tables. They all look
      >something like:
      >
      ><a href=this_page. php?table=mytab le1>the first table</a>
      ><a href=this_page. php?table=mytab le2>the second table</a>
      ><a href=this_page. php?table=mytab le3>the third table</a>
      >
      >etc.
      >
      >so the user clicks on a link and gets the table. now, when he goes back
      >to the main page, and chooses another link, he always returns to the
      >initial table, because the $table variable is still somehow "active"[/color]

      You should be looking at $_GET['table'], not $table.
      And turn off register_global s.
      [color=blue]
      >I tried to unset the $_GET array at the start of the code of the main
      >page, but still it does not work.[/color]

      Don't even try this. Altering the $_GET array is a lot like trying
      to resurrect someone by retouching their X-rays: editing a copy
      does not alter the original.
      [color=blue]
      >When i do a print_r($_GET) before and
      >after the unset, it shows me that in the $_GET array exists before the
      >unset, but is away after the unset, so everything should be fine.[/color]

      Consider $_GET read-only, since the browser does not get to see the
      modified copy.
      [color=blue]
      >But why does the $table variable still remain in the system?!?[/color]

      Because the browser sends it again (as $_GET['table'], hopefully
      not as $table). I'm not sure you have shown enough detail to
      determine why. The fact that you are using links relative to the
      current page might have something to do with it.

      Gordon L. Burditt

      Comment

      Working...