RE: ip address

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  function getIP() {
    if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"),
"unknown"))
    $ip = getenv("HTTP_CLIENT_IP");
    else if (getenv("HTTP_X_FORWARDED_FOR") &&
strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
    $ip = getenv("HTTP_X_FORWARDED_FOR");
    else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"),
"unknown"))
    $ip = getenv("REMOTE_ADDR");
    else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] &&
strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
    $ip = $_SERVER['REMOTE_ADDR'];
    else
    $ip = "x"; // if this happens, then oh noz :-(
    return $ip;
  }

-----Original Message-----
From: Ramil Sagum [mailto:ramil.sagum@xxxxxxxxx] 
Sent: Thursday, September 30, 2004 8:18 AM
To: balwantsingh@xxxxxxxxxxxxx
Cc: php-db@xxxxxxxxxxxxx
Subject: Re:  ip address

On Thu, 30 Sep 2004 11:00:35 +0530, balwantsingh
<balwantsingh@xxxxxxxxxxxxx> wrote:
> i tried the $_SERVER['REMOTE_ADDR'] it is giving ip address of server
which
> is hosting the webpage not the user's ip address.   pls. suggest how can
IP
> address of an user can be obtained.

what exactly did you do? the following script works:

===
<html><body>
Your IP Address is : 
<?php echo $_SERVER["REMOTE_ADDR"]; ?>
</body></html>
===


----

ramil

http://ramil.sagum.net

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux