I'm wanting to record the person's IP Address when they register an account on my database (php/mysql). How can I get the users IP Address?
Printable View
I'm wanting to record the person's IP Address when they register an account on my database (php/mysql). How can I get the users IP Address?
$Hostname = @gethostbyaddr($REMOTE_ADDR);
Thanks. How about the others? This returns blanks.
Code:$RemoteAddress = @gethostbyaddr($REMOTE_ADDR);
$RemoteHost = @gethostbyaddr($REMOTE_HOST);
$RemoteUser = @gethostbyaddr($REMOTE_USER);
$UserAgent = @gethostbyaddr($HTTP_USER_AGENT);
echo $Hostname;
echo "<br>";
echo $RemoteHost;
echo "<br>";
echo $RemoteUser;
echo "<br>";
echo $UserAgent;
echo "<br>";
Try
http://www.complex-sys.com/getenv.phpPHP Code:echo $RemoteAddress = getenv("REMOTE_ADDR") . "<br>" .
$RemoteHost = getenv("REMOTE_HOST") . "<br>" .
$RemoteUser = getenv("REMOTE_USER") . "<br>" .
$UserAgent = getenv("HTTP_USER_AGENT") . "<br>";
If some of them don't return, it's because of your server software. The REMOTE_USER does not return on my IIS server.
$REMOTE_ADDR is deprecated. Use $_SERVER['REMOTE_ADDR'].Quote:
Originally posted by bekkel
$Hostname = @gethostbyaddr($REMOTE_ADDR);
Thanks guys :wave:
not a sure fire way to get it. they can still be blank whateve way you do it. they can be behind a proxy or they can edit it so they don't show it. a lot of things.