I do not know much PHP at all but I want to check if this can be done, and if there are an available scripts?
Basically I have two sites for a friends business, one for the UK and one for Ireland.
At the minute I have a jump menu where they pick ther region and enter the site that way.
What i’d love is a script that will know where they are from and will put them on to the right site… e.g. if they are from Ireland when they land on the site they get redirected to the Ireland page?
Users from Scotland, England, N.Ireland Wales would go to the UK site.
Is there anyeasy way to achieve this?
Yes you can, it’s all down to the ip address, so you can create a database table with both ip’s for the UK and Ireland , then have php look for that visitors ip address, if it matches it will thake them to the countries website.
I have found this script which shows you how to go about making a database table and the php script.
Sorry, I have found a MySQL database file with the Englands,Scotlands and Irelands ip ranges. You can take a look here for your self, scroll down to the heading “CSV Format” and click the second link to download.
Also, give me about five minutes and I’ll post the ranges in this thread.
Sorry for the long delay, I’ve done the list for Great Britain and Ireland. It’s fairly big so I won’t post it in this thread, instead send me a pm with your email address and I’ll send you the file over.
Create a new table for the ip addresses this will come in handy if you wish to add more or update later:
CREATE TABLE `geo_blocks` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`begin_ip` INT(10) UNSIGNED NOT NULL,
`begin_num` INT(10) UNSIGNED NOT NULL,
`end_num` INT(10) UNSIGNED NOT NULL,
`country` VARCHAR(2) UNSIGNED NOT NULL,
`name` TEXT UNSIGNED NOT NULL,
PRIMARY KEY (`id`),
INDEX `idx_begin` (`begin_ip`),
INDEX `idx_end` (`end_ip`),
INDEX `idx_name` (`name`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
Then you will need to login phpMyAdmin and insert the data from the file you get from me by email.