Welcome Guest, Not a member yet? Register   Sign In
error encounter while including form_validation library
#2

First of all, when you share php code, please use the php button on the tool bar of the forum's editor window.

The best structure for handling forms with form validation is this:
PHP Code:
public function edit() 
{
   
$this->load->library('form_validation');
   
//set rules here in $rules array
   
$this->form_validation->set_rules($rules);

   if (
$this->form_validation->run() == FALSE) {
      
//display your form
   
}
   else {
      
//save form input to database
      //redirect to page which should appear after saving data
   
}


In this case, your form view should have this line:
PHP Code:
echo form_open();   // form is posted to original url
//display fields here
//display submit button here
echo form_close(); 
Reply


Messages In This Thread
RE: error encounter while including form_validation library - by Wouter60 - 06-01-2016, 01:01 PM



Theme © iAndrew 2016 - Forum software by © MyBB