Example of CodeIgniter Form Verification Method

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.