O'Reilly logo

CodeIgniter 2 Cookbook by Rob Foster

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Validating user input

Validating user input allows you to set rules against which input coming in from the user can be judged. For example, you may wish to enforce certain conditions on an e-mail field, most obviously checking for a valid e-mail syntax, but also the minimum and maximum length, and whether it is required. CodeIgniter can even look into a database and check for duplicate values. In this recipe, we're going to build a controller and view, which together will allow the user to input data and have it validated against rules that will be set; errors, if any, will be reported back to the user.

Getting ready

You'll need to be aware of a few things before getting started. The following is a table of all available CodeIgniter validation rules: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required