Codeigniter form_open – To create forms in Codeigniter form helper and form validation library is avalable which can be used easily. Here in this article we are going to explain how you can create forms and add validation in codeigniter using its helper & library.
Codeigniter form_open | Form | Helper | Library Example
, First of all, you need to load form helper and form validation library in controller function simply following the below steps-
1. Controller Part
In controller load helper & library.
Codeigniter form_open Example :
<?php class User extends CI_controller{ public function login() { $this-?>load->helper('form'); $this->load->library('form_validation'); $this->load->view('login_view'); } } |
After loading helper & library now you are able to create form fields & validations-
View Part | login_view.php
Form is created using form_open & form_close-
Codeigniter form_open Example :
<?php echo validation_errors(); ??> <?php echo form_open('user/login') ??> <br/> <br/> <?php echo form_close() ??> |
Codeigniter form_open Not Working ? | Fatal Error
Make sure you have loaded form helper & library to avoid the errors.