I need to display a different home page in US compared to the one designed for Europe (especially UK). Is this possible to achieve in PHP?
The PHP website that I have developed uses JS, Ajax and Bootstrap extensively.
I need to display a different home page in US compared to the one designed for Europe (especially UK). Is this possible to achieve in PHP?
The PHP website that I have developed uses JS, Ajax and Bootstrap extensively.
If the primary goal here is to cater to specific demographic groups, rather than trying to implement some sort of location-based lock-out mechanism, then instead of using a geo location database as primary guide, consider using the client's browser locale (c.f. Detect Browser Language in PHP).
Maxmind offers a neat (free) IP-based location look-up database available here: https://dev.maxmind.com/geoip/legacy/geolite/
$ip = $_SERVER['REMOTE_ADDR'];
$details = json_decode(file_get_contents("http://ipinfo.io/{$ip}/json"));
echo $details->city;
e.g. for ip 8.8.8.8 it gives
{
"ip": "8.8.8.8",
"hostname": "google-public-dns-a.google.com",
"city": "Mountain View",
"region": "California",
"country": "US",
"loc": "37.3860,-122.0838",
"org": "AS15169 Google Inc.",
"postal": "94040"
}