Example of CodeIgniter form verification method, codeigniter form
This example describes the CodeIgniter form verification method. We will share this with you for your reference. The details are as follows:
1. Write a View File myform. php In the Directory D: \ CodeIgniter \ system \ application \ views.
Then write a View File formsuccess. php.
2. Write a form. php controller file in the Directory D: \ CodeIgniter \ system \ application \ controllers.
<?phpclass Form extends Controller{ function index(){ $this->load->helper(array('form','url')); $this->load->library('validation'); $rules['username'] = "required"; $rules['password'] = "required"; $rules['passconf'] = "required"; $rules['email'] = "required"; $this->validation->set_rules($rules); // $this->validation->set_error_delimiters('<div class="error">','</div>'); $fields['username'] = 'Username'; $fields['password'] = 'Password'; $fields['passconf'] = 'Password Confirmation'; $fields['email'] = 'Email Address'; $this->validation->set_fields($fields); if ($this->validation->run()==false) { $this->load->view('MyView/myform'); }else { $this->load->view('MyView/formsuccess.php'); } }}?>
3. Access http: // localhost: 8888/index. php/form/index
OK. The results are all displayed.