SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    England
    Posts
    702
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Get ALL Variables From URL

    I need to pass EVERY variable from the URL, whether it's part of an array or not, to another page. Is there a way to do this without doing the usual $_GET['var'] and then putting them on the end of the next page? It's basically a page in an iFrame and I need to take variables passed to the main page and pass them to the one in the iFrame (the iFrame only needs the original data so there's no problem with updating here).

    I wondered if PHP has a function that basically grabs everything after the ? on the URL and allows me to paste that onto the end of another URL without knowing what any of the variables are in the first place?

    Yes? No?

    Thanks guys

  2. #2
    SitePoint Guru Ruben K.'s Avatar
    Join Date
    Jun 2005
    Location
    Alkmaar, The Netherlands
    Posts
    693
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    foreach( $_GET as $k => $v )
    {
        echo 
    "$k$v <br />";


  3. #3
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Yeh, there is a variable which is the query string... I forget which though. Try looking at a phpinfo, it'll be in there

    Edit: $_SERVER["QUERY_STRING"]

  4. #4
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perhaps I understood wrong, but I guess sessions would be better...

    Anyways:
    $array = explode('?', $_SERVER['REQUEST_URI']);
    $everythingthequestionmark = $array[1];
    echo $everythingthequestionmark;

    print_r($_SERVER) is your friend

  5. #5
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    England
    Posts
    702
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks, I shall try these and see which solution is best for me. I think $_SERVER['REQUEST_URI'] was the one I was thinking of so I'll try it and see.

    Thanks again

  6. #6
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    England
    Posts
    702
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Ah, Stormrider, didn't see your edit, yes, $_SERVER["QUERY_STRING"] was the one I was after, worked perfectly as planned, thank you. I see you're in Nottingham; Mansfield here. My wife works at Notts Uni though

  7. #7
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Off Topic:

    Ah OK, I went to Notts Uni, graduated in 2005 and work in the city centre now


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
  •