Print Out Browsers IP Adress

Discussion in 'Programming' started by emil2k, Jan 21, 2006.

  1. #1
    Hey Everybody,

    I wanted to ask if anybody new the simple snippet of code I need to put into and html page to show the IP adress of the person who is browsing, I've seen it on several pages so I know it can be done, I need it for testing.

    Thanks
     
    emil2k, Jan 21, 2006 IP
  2. iShopHQ

    iShopHQ Peon

    Messages:
    644
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Not in HTML

    In ASP:
    request.servervariables("remote_addr")
    OR
    request.servervariables("remote_host")

    There's probably a JavaScript to do it too that would work in a flat HTML page
     
    iShopHQ, Jan 22, 2006 IP
  3. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #3
    In PHP with Proxy Detection:

    
    if (getenv(HTTP_X_FORWARDED_FOR)) {
    		$ipaddress = getenv(HTTP_X_FORWARDED_FOR);
    	    } else {
            $ipaddress = getenv(REMOTE_ADDR);
        }
    echo "Your IP Address: " . $ipaddress;
    
    PHP:
     
    T0PS3O, Jan 22, 2006 IP
  4. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #4
    Thanks for the code TOPS30. :)
     
    ResaleBroker, Jan 22, 2006 IP
  5. wasabi

    wasabi Guest

    Messages:
    58
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    you better use $_SERVER[HTTP_X_FORWARDED_FOR] and $_SERVER[REMOTE_ADDR] instead of getenv function.
     
    wasabi, Jan 24, 2006 IP
  6. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #6
    True. I believe getenv is deprecated and PHP people favour indeed $_SERVER.
     
    T0PS3O, Jan 24, 2006 IP
  7. tccoder

    tccoder Peon

    Messages:
    69
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    yup, getenv will not be supported in further versions, which will make ur script stop working.

    always avoid deprecated tags and functions.
     
    tccoder, Jan 28, 2006 IP