SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Geting information from a url

    I need some help... I am new to PHP, I just started about a week ago, and I can not find out how to get information from a url. What I want to do is this:

    I want to make a text box, so when someone types in a name in it, that name will go up into the url box, and get information from that url. Here is an example:

    If I type in Emzz18 in the text box, under the text box (not on another page) the information from "http://hiscore.runescape.com/index_lite.ws?player=emzz18" will be there, and if I type in Red Wings013, the information from http://hiscore.runescape.com/index_lite.ws?player=red wings013 will go there.

    Would anyone be able to help me? I think I use the POST method, but I don't really know...

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You would use the GET method, not POST, to put things in the query string of the URL. You then access them from the array $_GET which PHP automatically creates for you.

    Example form:
    PHP Code:
    <form action="process.php" method="GET">
    Enter Player: <input type="text" name="player" value="" />
    <
    br />
    <
    input type="submit" value="Submit" />
    </
    form
    Example process.php:
    PHP Code:
    <?php

    echo "The player name you entered was: ";
    echo 
    $_GET['player'];

    ?>

  3. #3
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The form part looks right, but the php doesn't. So say if I put in "emzz18" in the box, then in the url would be http://hiscore.runescape.com/index_l...?player=emzz18 (click on the url, and you will see a lot of numbers). I want to get all the numbers onto the page with the form.

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Whatever you want to do with "emzz18" on the page with his name in the URL is the code that you write. I am not omniscient, I don't know what that is, I can only show you how to get the name out of the URL to use in that code.

  5. #5
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I want to connect the text input field with the url to get the data? Does that help? So whatever I type into the text box will go onto the last part of the url...

  6. #6
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The form takes care of that.

    Any form submitted with GET as the method results in a query string where the input names become the keys and their values the values in the URL.

    You don't have to write any code, it's part of the HTTP specification. Try it.


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
  •