-1

I've created an age verification splash page for a liquor company using PHP, but didn't consider different legal drinking ages across the globe. What's the easiest way to have my age gate check for the entered country's drinking age?

Also, instead of having a user enter their country, is there a way to just pull it from an IP address?

PeeHaa
  • 71,436
  • 58
  • 190
  • 262
  • 4
    "are you of legal drinking age in your country?" yes / no – Nanne Apr 16 '13 at 23:58
  • There was a similar 'hot question' recently in ux.stackexchange.com: [Are age verification banners effective?](http://ux.stackexchange.com/q/38154/938236). Nanne is best answer so far, although not an 'answer'. – Francisco Presencia Apr 17 '13 at 00:00
  • Partial possible duplicate of http://stackoverflow.com/questions/4890774/geoip-zip-code-query/1558208 – AbsoluteƵERØ Apr 17 '13 at 00:03

3 Answers3

2

It will be challenging, and potentially costly, to get accurate location data for all customers. GeoIP APIs aren't always correct, and you're often rate-limited to a certain number of queries per hour on free or low-cost searches. Plus you then need accurate and maintainable data sets on drinking ages, and need to account for countries / states that have different drinking ages for different types of beverage. You also need to consider countries that have an outright ban on alcohol.

I'd say you're over-engineering this.

Instead of asking for an age, why not just ask them to check a box stating that they are above the minimum drinking age for their current location?

For example:

By checking this box, you agree that you are of the minimum age required by your country or state to purchase and consume alcoholic beverages.

Or more generally, in a way that covers illegality of alcohol:

By checking this box, you agree that you are legally entitled to purchase alcohol in your current state or country of residence.

Polynomial
  • 27,674
  • 12
  • 80
  • 107
0

You can try to use GeoIP. They even provide a very good list of IP ranges that you could use, to detect what is the location of your visitor.

Probably, you'll be needing to specify a legal age to drink per country, maybe on an array, and you'll then ask the user his birth date. After he answers, you check the values with the array (always corresponding the country), then you or allow his entrance or not.

Ivo Pereira
  • 3,410
  • 1
  • 19
  • 24
  • So let's make a system that uses a huge IP database from across the globe and compare that with an user input year? `A chain is only as strong as its weakest link` – Francisco Presencia Apr 17 '13 at 00:03
  • The user asked how, I said him how. You cannot have a reliable way to say "YES, THIS USER IS FROM HERE". That could never be true. And by the way, GeoIP makes available some pieces of their database. – Ivo Pereira Apr 17 '13 at 00:05
0

GeoIP facilities exist, but keep in mind that the free versions are wildly inaccurate, and even the paid subscriptions have errors. Check this site: http://www.maxmind.com/en/geolocation_landing

Having resolved a country a simple DB table should be enough to store the legal drinking age. I think you're overcomplicating it though - an age question is easily fooled, so why try to make it too strict. Might as well replace it with just the 'are you allowed to drink in your country' question which is just as easily fooled, and of same legal value.

Niels Keurentjes
  • 41,402
  • 9
  • 98
  • 136