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 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    North East England
    Posts
    853
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How do I get the user's IP?

    ^^^as titled
    [+] Computer/PC issues [+] Silverpaw3D
    ------------------------------------------------
    Never buy a dwarf with learning disabilities...

    ...it's not big, and it's not clever.

  • #2
    New Coder
    Join Date
    Aug 2002
    Location
    Toronto, Canada
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ...

    this should be the easiest way of doing that ...

    <? echo $HTTP_SERVER_VARS["REMOTE_ADDR"] ?>

    HormonX

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    North East England
    Posts
    853
    Thanks
    0
    Thanked 0 Times in 0 Posts
    $REMOTE_ADDR

    is quite easy too, cheers anyhoo
    [+] Computer/PC issues [+] Silverpaw3D
    ------------------------------------------------
    Never buy a dwarf with learning disabilities...

    ...it's not big, and it's not clever.

  • #4
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts
    Can you get the IP address of a computer behind a proxy server?

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    183
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Not sure about the proxy thing, but a few other ways to get the IP

    getenv ("REMOTE_ADDR");

    or

    $_SERVER["REMOTE_ADDR"];

    Offtone.com - In the works...

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP Code:
    function getip() {
        if (isSet(
    $_SERVER)) {
            if (isSet(
    $_SERVER["HTTP_X_FORWARDED_FOR"])) {
                
    $realip $_SERVER["HTTP_X_FORWARDED_FOR"];
            } elseif (isSet(
    $_SERVER["HTTP_CLIENT_IP"])) {
                
    $realip $_SERVER["HTTP_CLIENT_IP"];
            } else {
                
    $realip $_SERVER["REMOTE_ADDR"];
            }
        
        } else {
            if ( 
    getenv'HTTP_X_FORWARDED_FOR' ) ) {
                
    $realip getenv'HTTP_X_FORWARDED_FOR' );
            } elseif ( 
    getenv'HTTP_CLIENT_IP' ) ) {
                
    $realip getenv'HTTP_CLIENT_IP' );
            } else {
                
    $realip getenv'REMOTE_ADDR' );
            }
        }
        return 
    $realip;    

    You might need to amend the $_SERVER calls to $HTTP_SERVER_VARS (note: I'm pretty sure I copied that from php.net somepage so don't blame me if it works properly )
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.


  •  

    Posting Permissions

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