Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14346

a form validation issue

$
0
0
Hi,
I have a form validation issue.

here's the code
Code:
  $this->form_validation->set_rules('pass','password','required|min_length[8]|callback_access');

When I used CI 3.0.6 , it could run "required", "min_length[8]" and "callback_access" function together.
But it won't work together when I update to CI 3.1.0.

If I remove "callback_access" function (as bellow), then "required" and "min_length[8]" can be work correctly.
Code:
  $this->form_validation->set_rules('pass','password','required|min_length[8]');
the callback function:

Code:
public function access(){

   $acc  = $this->input->post('acc', TRUE);
   $pass = md5($this->input->post('pass', TRUE));

   $user = $this->login->select_user($acc);    //model

   if(!empty($user)){

       if($user->db_password == $pass){
           //save sessions
           return TRUE;
       }else{
           $this->form_validation->set_message('access',"account or password was incorrect");
           return FALSE;
       }
   }else{
       $this->form_validation->set_message('access',"account or password was incorrect");
       return FALSE;
   }
}
How do I fix this?
Thanks!!

Viewing all articles
Browse latest Browse all 14346

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>