Creating a helper to work with a person's date of birth

From time to time, you'll need an age verification script, a method to ascertain whether or not a user is of a certain age. Based on their age, they may be allowed, or disallowed, from viewing content, for example, a website that promotes adult products, such as alcohol or tobacco or a games site that promotes a game rated for certain ages. The code in this recipe helps you to ascertain a user's age, compares that against a minimum age requirement, and displays an HTML file accordingly.

How to do it…

We're going to create five files:

  • /path/to/codeigniter/application/controllers/register.php: This is the controller for our recipe
  • /path/to/codeigniter/application/helpers/dob_val_helper.php: This ...

Get CodeIgniter 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.