Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Mar 2005
    Posts
    114
    Thanks
    4
    Thanked 3 Times in 3 Posts

    Get stuff following the ?

    First of all, GREAT tutorials in the FAQ section. It really helped . But now I need to know one last thing.

    How can I pass along variables in the url? I know I have seen it done (http://www.site.com?user=Josh&age=42...uff%20to%20buy) but I myself do not know how to get that information out. A simple question, I know. Any help?

  • #2
    Regular Coder
    Join Date
    Jul 2004
    Posts
    201
    Thanks
    8
    Thanked 1 Time in 1 Post
    Ah, spmething I can help someone with

    Serex and SeeITSolutions helped me with this a couple days ago. see here:

    useing ?name=blah - Some help

    Its easy really, if you where to have your url like so:

    yourdomain.com?name=help

    then in ur php page you would have:

    PHP Code:
    <?
    $name 
    $_GET['name'];
    echo 
    "$name";
    ?>
    And that would output to the page help.

    Any more info needed?

  • #3
    Regular Coder
    Join Date
    Mar 2005
    Posts
    114
    Thanks
    4
    Thanked 3 Times in 3 Posts
    thanks, sites almost done . Never thought I coulda been doing this before, but hey it's working!

  • #4
    Regular Coder
    Join Date
    Mar 2004
    Location
    Australia
    Posts
    217
    Thanks
    0
    Thanked 1 Time in 1 Post
    As anthony mentioned you can use $_GET['varname'] to 'get' any values passed through the URL. just remember after the first ? you need to use &. i.e

    page.php?name=john&age=17&sex=male

    so to get all of those just use

    $name = $_GET['name'];
    $age = $_GET['age'];
    $sex = $_GET['sex'];

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    If your careful, you can also use an extract() function combined with the QUERY_STRING in order to retreive all of your variables in one shot. The key word is if you are careful. Doing this method without any type of control allows a client to specify whatever variables they would like to use, not just the ones you would like to use.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •