CodeIgniter form verification
To use CodeIgniter form verification, add:
?
12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
$ This-> load-> helper ('form'); $ this-> load-> library ('form _ validation '); // Set verification rules/* $ config = array ('field '=> 'Category', 'label' => 'Category name ', 'rules' => 'delimiter'), array ('field' => 'title', 'label' => 'title ', 'rules' => 'required'); $ this-> form_validation-> set_rules ($ config); */$ this-> form_validation-> set_rules ('Category ', 'Category name', 'required'); $ this-> form_validation-> set_rules ('title', 'title', 'required '); // matches is equal to another value. matches [title] // unique is_unique value is_unique [table. field] (table/field) // min_length min length min_length [6] // max_length Max length max_length [12] // valid_email verification email // valid_emails verifies multiple emails, separate // valid_ip verification IP // valid_base64 verification Base64 // alpha letter // alpha_numeric combination of letters and numbers // alpha_dash combination of letters, numbers, and underlines // numeric number or number string // integer // is_numeric numeric or numeric string // when multiple rules are used together, add | connect, for example: required | valid_email | is_unique [users. email] if ($ this-> form_validation-> run () = FALSE) {// execution upon verification failure} else {// execution upon verification success} |
On the verification page:
?
123 |
Echovalidation_errors (); // display all error messages echoform_error ('title'); // display a single error message echoset_value ('title'); // Set the form value |