I want to collect basic user information when they land on an index page, such as:

Zip Code

I've looked into sites such as ipinfo.io that offer a service regarding these details, but think it may be easier to collect the same info via PHP. From some sample PHP code I've looked at, it seems easy and possible.

My question is what would generally be a better option: PHP or using a service (the service limits the amount of hits processed per day, 10,000, so that is a consideration)?

I am just looking for advice on this at this point, the best options to consider, and possible issues regarding this before I attempt to implement this.

Thanks in advance!

6 Months
Discussion Span
Last Post by Dani

You can use PHP to retrieve a user's IP address. And you can use the JavaScript-based HTML5 geo API to retrieve a user's latitude and longitude (coordinates), provided they agree to it.

However, you need a third party service or library or something to actually determine a user's city, state, country, zip code, area code, etc.

I would recommend Geo2IP. That's what I've been using for years and there is a free version that lets you download their database and use it directly, albeit it's a little less accurate. However, what I like about it is that it doesn't depend on any third party API calls, so once you download it you can use it locally without limitation.

Edited by Dani


If that's the same one as I used a few years ago, be aware the file is ginormous (as you may expect).


Sorry, I wrote Geo2IP and it's actually GeoIP2. And it converts the IPs you have to geos. See, I was almost right.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.