I am trying to get a location from a uses IP address. There is a lot of topics on how to do this. I really like this one, it works and is very clear. The IP address used in the example finds the location somewhere in germany, but when I use my IP address (192.168.0.7) everything comes back as unknown. When the site is only online I wouldn't be using my IP address I would be finding the users IP address using PHP.
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$ip = '192.168.0.7'; //replace with my IP address
I have also came across this site which finds my IP address, which is quite accurate except the numbers are different. 2.126.219.101
Is there a way I can test what I have on localhost to obtain my IP address using the above method or is there something wrong with my IP address.