tags:

views:

26

answers:

1

hey guys, i wonder how difficult it is (and what programming languages i need) to retrieve a users ip-adress and based on it's location i show a different ad on my website.

do you know any tutorials or can you tell what i have to search for to find a answer to that.

regards matt

+1  A: 

The IP is usually very easy to retrieve in virtually any HTTP server environment. How to do so depends on the language and environment, but it's usually only a line of code. Be aware that if the user is running through a proxy or VPN, you won't be able to get their true IP, but only that of the proxy.

To determine the physical location, you'll need to use an IP Geolocation service. There are some free ones, but the paid ones are usually more accurate.

jay.lee
ok, i thought that e.g. my country's ip-addresses always start with the same few numbers. so i thought it's easy to retrieve if someone looks on my site from inside or outside my country. If no match, just show something random. Does anybody know a good geolocation service?
not having used them, I can't recommend a good one from experience. But Google seems to be pretty friendly about making suggestions :)
jay.lee