(03-17-2015, 12:19 AM)Avenirer Wrote: As you can see, it's a validation library, not a cleaning one. Its purpose is only to validate the data.
But even Codeigniter 2's validation library will clean data. This is from the manual.
Quote:Prepping Data
In addition to the validation functions like the ones we used above, you can also prep your data in
various ways. For example, you can set up rules like this:
Code:
$this->form_validation->set_rules('username', 'Username',
'trim|required|min_length[5]|max_length[12]|xss_clean');
$this->form_validation->set_rules('password', 'Password', 'trim|required|matches[passconf]|md5');
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'trim|required');
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
In the above example, we are "trimming" the fields, converting the password to MD5, and running the username through the "xss_clean" function, which removes malicious data. Any native PHP function that accepts one parameter can be used as a rule, like htmlspecialchars, trim, MD5, etc.
Note: You will generally want to use the prepping functions after the validation rules so if there isĀ an error, the original data will be shown in the form.
Hey, don't work without a PHP debugger. Several free IDEs have this features built in. Two are NetBeans and CodeLobster. Without a debugger, it's like you're driving with a blindfold on -- you are going to crash!