PDA

View Full Version : How to auto detect user's location and redirect them to a page?



woodwinked
08 Sep 2010, 10:34 AM
Hi there, I'm new to web design/development I just joined webdevforums.com today!

I'm building a classifieds site which has city-specific sections (e.g. city1.domain.com, city2.domain.com, etc).

On the main page at domain.com I want to either:
1. List the city-specific subdomains so that the user can choose one, and then I want to remember what they selected so that they next time they go to domain.com the site remembers and auto redirects them to the last city they picked.

or

2. Auto detect what city the user is in and send them to the corresponding subdomain (e.g. if they are in city1 then they'd be automatically redirected to city1.domain.com)

Help?
I'm using Wordpress MU if that is any help.

TheBatmanOfPHP
18 Sep 2010, 01:03 PM
You will have fun setting this up. theres a thing called geoip and its free. You can get it from maxmind.com
it is a php script. it comes as "geoip.inc" and "geoip.dat" you change the geoip.inc into geoip.inc.php and then you spend alot of time trying to figure out how intergrate in in to a page.
Great fun!!!!!!!!!!!!!!!!
You will love it.