View Single Post
  #1  
Old May 11th, 2011, 01:11 PM
cgarvey cgarvey is offline
 
Join Date: Mar 2011
Posts: 33
Default Geo Targeting to one specific merchant.

Hi Eric and Team,

I have this code to redirect people to a certain page based on their Geographical location.
The trouble is, I'm not sure how to use it. Only one of my merchants ships outside of the US, so I want to setup a page with only this merchants products and use the code below to have international users open to this page as opposed to how it opens now, with all my merchants.
I need to know where to post the code to and do I make a new page or category for this one merchant. Any help would be great.

Here is the link to my site: http://allamericansneakers.com

Here is the code, it will need to be modified, but I think I can handle that.

<?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 redirect US visitors to CNN
header('Location: http://www.cnn.com/');
exit;
default:
// The rest of the world can go to BBC
header('Location: http://www.bbc.co.uk/');
exit;
}

?>