独自の関数で検証クラスを拡張しようとしていますが、チェックをスキップしているようです。
私のコード
public function login_validation(){
$this->load->library('form_validation');
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email|xss_clean|callback_validate_credentails');
$this->form_validation->set_rules('password', 'Password', 'trim|required|md5');
if($this->form_validation->run()){
#redirect('home');
//Just to check
echo "login success";
}
else{
$this->load->view('view_login');
}
}
私の検証資格情報関数は次のようになります。
public function validate_credentials(){
//loads model_user
$this->load->model('model_users');
//checks if login_validate function in model_users return true
if($this->model_users->login_validate()){
return true;
}
else{
//set validation message
$this->form_validation->set_message('validate_credentails','Incorrect Username/Password');
return false;
}
}
必要に応じて、model_users の login_validate 関数。
public function login_validate(){
$this->db->where('email', $this->input->post('email'));
$this->db->where('password', md5($this->input->post('password')));
$query = $this->db->get('users');
if($query->num_rows() == 1){
return true;
}
else {
return false;
}
}
こんな症状は初めてなのですが何か間違っているのでしょうか?私はこれにあまりにも多くの時間を費やしました:(