Skip to main content

How to use form Validation in Codeigniter?

  Use form Validation in Codeigniter

Paste in Codeigniter

if($this->input->post('login')){

$email=$this->input->post('login_email');

$password=$this->input->post('login_password');

        $this->load->library('form_validation');

$this->form_validation->set_rules('login_email', 'Email', 'required|valid_email'); 

                $this->form_validation->set_rules('login_password', 'Password', 'required|min_length[10]'); 

                if ($this->form_validation->run() == FALSE) { 

//redirect('dashboard');

//echo 'not-working';

            } 

            else { 

$query = $this->Customer_model->login_detail($email,$password);

if(count($query)>0){

//session_start();

$this->session->set_userdata('ID',$query[0]['ID']);

redirect('dashboard', 'refresh');

}

else{

redirect('register'); 

}  

}


Comments

Popular posts from this blog

How to check date format in PHP?

Check date format in PHP function isCorrectDateFromat($date){     if(!empty($date)){         $dateString = $date; // Replace this with your date string         $format = "Y-m-d"; // Replace this with your expected date format         $dateTime = DateTime::createFromFormat($format, $dateString);         if ($dateTime === false) { /*             echo "The date is not in the correct format."; */         } else {             $errors = DateTime::getLastErrors();             if (empty($errors)) { /*                 echo "The date is in the correct format."; */                 return true;             } else { /*                 echo "...