how do i get a users ip address?

A

Anonymous

Guest
Subject is fairly self explanitory.
I tried doin this -

$host = $REMOTE_ADDR;
print "$host";

but apparently it isn't that simple.
 
Hi,

There are a great many things you can get, try putting this in a script to see the full list.

<?
phpinfo();
?>

To pull one out simply put:
<?
$ip_address=getenv(REMOTE_ADDR);
echo"$ip_address";
?>
replace REMOTE_ADDR to get the others.

regards,

Hadleigh.
 
or you could put:

<?PHP
$ip_addy = $_SERVER['REMOTE_ADDR'];
echo $ip_addy;
?>
 
just having $REMOTE_ADDR will only work if register_globals is turned on. PHP 4.2 and higher have this turned off by default.

bobaloo's example $_SERVER['REMOTE_ADDR'] should work
 
Back
Top