I am researching ways of making ads actually relevant to people. How can I get the location of a visitor, who just loaded my page? I'm not talking IP Geo-location
, I'm talking the exact latitude and longitude of a user, that I could later store in a database. Is there an API
or something to allow me to get those values in PHP
variables, using something like GPS
?
Asked
Active
Viewed 950 times
1

Alive to die - Anant
- 70,531
- 10
- 51
- 98

Andre Andre Rotaru
- 55
- 5
-
This link is of help to you http://stackoverflow.com/questions/11864174/how-to-get-users-geolocation – Amit Ray Jul 02 '16 at 07:16
1 Answers
1
First get visitor's location details from IP address
How to get user IP Address in PHP
<?php
$ip = $_SERVER['REMOTE_ADDR'];
echo $ip;
?>
How to get user/ visitor Location in PHP
<?php
require_once("userip/ip.codehelper.io.php");
require_once("userip/php_fast_cache.php");
$_ip = new ip_codehelper();
$real_client_ip_address = $_ip->getRealIP();
$visitor_location = $_ip->getLocation($real_client_ip_address);
$guest_ip = $visitor_location['IP'];
$guest_country = $visitor_location['CountryName'];
$guest_city = $visitor_location['CityName'];
$guest_state = $visitor_location['RegionName'];
echo "IP Address: ". $guest_ip. "<br/>";
echo "Country: ". $guest_country. "<br/>";
echo "State: ". $guest_state. "<br/>";
echo "City: ". $guest_city. "<br/>";
?>
For more detail kindly visit below link

Anand Jain
- 779
- 2
- 10
- 32