Get Userlocation using ip address in PHP
Let's have look.
Please share your comments and feedback.Thanks.Please subscribe my updates via email.
Let's have look.
index.php
<?php
/*Get user ip address*/
$ip_address=$_SERVER['REMOTE_ADDR'];
/*Get user ip address details with geoplugin.net*/
$geopluginURL='http://www.geoplugin.net/php.gp?ip='.$ip_address;
$addrDetailsArr = unserialize(file_get_contents($geopluginURL));
/*Get City name by return array*/
$city = $addrDetailsArr['geoplugin_city'];
/*Get Country name by return array*/
$country = $addrDetailsArr['geoplugin_countryName'];
if(!$city){
$city='Not Define';
}if(!$country){
$country='Not Define';
}
echo '<strong>IP Address</strong>: '.$ip_address.'<br/>';
echo '<strong>City</strong>: '.$city.'<br/>';
echo '<strong>Country</strong>: '.$country.'<br/>';
?>
/*Get user ip address*/
$ip_address=$_SERVER['REMOTE_ADDR'];
/*Get user ip address details with geoplugin.net*/
$geopluginURL='http://www.geoplugin.net/php.gp?ip='.$ip_address;
$addrDetailsArr = unserialize(file_get_contents($geopluginURL));
/*Get City name by return array*/
$city = $addrDetailsArr['geoplugin_city'];
/*Get Country name by return array*/
$country = $addrDetailsArr['geoplugin_countryName'];
if(!$city){
$city='Not Define';
}if(!$country){
$country='Not Define';
}
echo '<strong>IP Address</strong>: '.$ip_address.'<br/>';
echo '<strong>City</strong>: '.$city.'<br/>';
echo '<strong>Country</strong>: '.$country.'<br/>';
?>
city:not defined ..??? what's problem?
ReplyDeleteits real good
ReplyDeleteits good
ReplyDelete