Click to See Complete Forum and Search --> : Problem with getenv?


k0r54
02-15-2007, 05:55 AM
Hi,

I am using this code to get the users ip addy


if (getenv("HTTP_X_FORWARDED_FOR")) {
$users_ip = getenv("HTTP_X_FORWARD_FOR");
$users_host = gethostbyaddr($users_ip);
} else {
$users_ip = getenv("REMOTE_ADDR");
$users_host = gethostbyaddr($users_ip);
}



I am gettin an erro that says gethotbyaddr is not a valid ipv4 or ipv6 address.

So I checked and it seams the error is gettin the ip address. It works on my local webserver but not on remote so its prob because different versions.

I then tried to change getenv to $_SERVER but tna

any help would be brill

thanks
k0r54

MrCoder
02-15-2007, 09:32 AM
$users_ip = $_SERVER['REMOTE_ADDR'];
$users_host = gethostbyaddr($users_ip);


Does that work for you?