Hi All,
I want to get IP address of each user using PHP. I have tried to use
$ip = $REMOTE_ADDR;
or
$ip = getenv(REMOTE_ADDR);
, but neither of them can retreive the IP of users. I aslo used isset($REMOTE_ADDR) to test whether $REMOTE_ADDR is set or not, the result is that $REMOTE_ADDR is not set (return false from isset()).
However, I called phpinfo() and I can see
HTTP_SERVER_VARS["REMOTE_ADDR"] is set to the IP of my PC. I don't know what's wrong. Can anyone help me?
A part of my php.ini:
;;;;;;;;;;;;;;;;;
; Data Handling ;
;;;;;;;;;;;;;;;;;
variables_order = "EGPCS" ; This directive describes the order in which PHP registers
; GET, POST, Cookie, Environment and Built-in variables (G, P,
; C, E & S respectively, often referred to as EGPCS or GPC).
; Registration is done from left to right, newer values override
; older values.
register_globals = On ; Whether or not to register the EGPCS variables as global
; variables. You may want to turn this off if you don't want
; to clutter your scripts' global scope with user data. This makes
; most sense when coupled with track_vars - in which case you can
; access all of the GPC variables through the $HTTPVARS[],
; variables.
register_argc_argv = On ; This directive tells PHP whether to declare the argv&argc
; variables (that would contain the GET information). If you
; don't use these variables, you should turn it off for
; increased performance
track_vars = On ; enable the $HTTPVARS[] arrays, where * is one of
; ENV, POST, GET, COOKIE or SERVER.
gpc_order = "GPC" ; This directive is deprecated. Use variables_order instead.
========================================
Platform:
Winnt 4.0 Server, IIS 4, PHP4.0.2 (using ISAPI)
Thanks in advance,
Albert