This example describes the CodeIgniter form verification method. Share with you for your reference, specific: 1. Write a View File myform. phphtmlheadtitleMyFormtitleheadbodyphpecho $ this-validation-error_string in the d: CodeIgnitersystemapplicationviews directory; phpechoform_open (
This example describes the CodeIgniter form verification method. Share it with you for your reference. The details are as follows: 1. write a View File myform in the Directory D: \ CodeIgniter \ system \ application \ views. php htmlheadtitleMy Form/title/headbodyphp echo $ this-validation-error_string; php echo form_open (
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.
My Form<?php echo $this->validation->error_string;?><?php echo form_open('form/index');?>UsernamePasswordPassword ConfirmEmail Address
Then write a View File formsuccess. php.
My FormYour form was successfully submitted!<?=anchor('form', 'Try it again!'); ?>
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('','
'); $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.