Hey all,
I am using the script below to automatically bring the user to their "home" page. I have 3 now, US which is the main page .com, CA which is canadian, .com/ca and UK, which is .com/uk
I am canadian, so it brings me to the /ca page, but when I try to goto the US main page, it will not let me, but it lets me goto the UK page. If a Canadian wanted to look in US page, I am afraid he will not be allowed, so I am looking for a script that will by pass this, or if not, at least exclude my IP address from the script, so I can actually look at the main page.
Thanks
here is a sample of the script. at the bottom, I just put in uk, ca and us as the default
Download
Contact
Sample Scripts: Country based redirection
<?php
$server = ''; // MySQL hostname
$username = ''; // MySQL username
$password = ''; // MySQL password
$dbname = ''; // MySQL db name
$db = mysql_connect($server, $username, $password) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$sql = 'SELECT
country
FROM
ip2nation
WHERE
ip < INET_ATON("'.$_SERVER['REMOTE_ADDR'].'")
ORDER BY
ip DESC
LIMIT 0,1';
list($country) = mysql_fetch_row(mysql_query($sql));
switch ($country) {
case 'se':
// Get the swedish to a swedish newssite
header('Location: http://www.thelocal.se/');
exit;
case 'us':
// And let the folks from american go to CNN
header('Location: http://www.cnn.com/');
exit;
default:
// The rest can go to BBC
header('Location: http://www.bbc.co.uk/');
exit;
}
?>