php - Form validation is not working in codeigniter -


i working codeigniter. have created 1 function add university form.

function add_uni_admin() {     $user_id = $this->session->userdata("user_id");     if (!empty($user_id)) {                          $uni_name = $this->input->post("uni_name");             $uni_image = $this->input->post("uni_image");             $uni_email = $this->input->post("uni_email");             $phn_no = $this->input->post("phn_no");             $m_no = $this->input->post("m_no");             $address = $this->input->post("address");             $password = $this->input->post("pass");              $this->form_validation->set_rules('uni_name', 'university name', 'required');                            $this->form_validation->set_rules('uni_email', 'email', 'required|valid_email');             $this->form_validation->set_rules('phn_no', 'phone number', 'required');             $this->form_validation->set_rules('m_no', 'mobile number', 'required');             $this->form_validation->set_rules('address', 'address', 'required');             $this->form_validation->set_rules('pass', 'password', 'required|matches[conf_pass]');             $this->form_validation->set_rules('conf_pass', 'confirm password', 'required');              if ($this->form_validation->run() == false) {                 $this->load->view("admin/add_uni_admin");                                    } else {                 echo "successfull";exit;             }                } else {         redirect(base_url());     } } 

when submit form without filling field not give error.here have added form_validation library autoload.php file , added form helper in it.

so code should have write display errors?

use echo validation_errors() in view display errors.

<html> <head>   <title>my form</title> </head> <body>  <?php echo validation_errors(); ?>  **your form here.**  </body> </html> 

Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -