On maxmind's webste, download GeoIP.dat and geoip.inc. Since you already named one of their functions, I'll assume you did this already.
To get the country code (US, CAN, UK, etc), use the following code:
PHP Code:
$gi = geoip_open("/your/absolute/path/to/GeoIP.dat",GEOIP_STANDARD);
global $country;
$country = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
geoip_close($gi);
The variable $country will contain the country code.
From there, you just use a simple if statement like:
PHP Code:
if ($country == 'US') {
//US ONLY
} elseif ($country == 'UK') {
//UK ONLY
} else {
//EVERYONE ELSE
}
Bookmarks