SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: $_get

  1. #1
    SitePoint Evangelist Deano's Avatar
    Join Date
    Mar 2003
    Location
    Derbyshire, UK
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy $_get

    Hi all, Ive run into a little problem.

    What Im trying to do is pull an id# all goes well with pulling an id from one page into antother, however when trying to build alink with the id# things start to go bent :



    this works fine and displays the correct id# which is 8
    PHP Code:
    echo $_GET['get_listings'] ; 
    This is directly below the above code and for some reason fails to pull the $get_listing number
    Code:
    <a href="add_link.php?get_listings=$get_listings">
    have I missed something or is it getting late in the day ?
    Regards
    Deano

  2. #2
    SitePoint Evangelist Waffles's Avatar
    Join Date
    Nov 2005
    Posts
    435
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?
    echo '<a href="add_link.php?get_listings='.$_GET['listings'].'">';
    ?>
    $get_listings isn't a superglobal, whereas $_GET[''] is.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    Williamsport, PA
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The context of that last bit of code is a little too vague for me to figure out exactly what the problem is. Is that anchor link inside an echo? If so it should be:

    Code:
    echo "<a href=\"add_link.php?get_listings={$_GET['get_listings']}\">";
    or, if register_globals is turned on,

    Code:
    echo "<a href=\"add_link.php?get_listings=$get_listings\">";
    Of course you might want to do a little validation on that GET request variable before you go pasting it back into other links.

  4. #4
    SitePoint Evangelist Deano's Avatar
    Join Date
    Mar 2003
    Location
    Derbyshire, UK
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Waffles, ths that worked out a treat.

    Coffee Ninja, I slightly understand what your saying, would this somehow help injection attacks ?
    Regards
    Deano


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
  •