这是我的模型代码
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Model_users extends CI_Model() {
public function can_log_in(){
$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;
}
}
}
?>
这是控制器的代码
public function validate_credentials(){
$this->load->model('model_users');
if($this->model_users->can_log_in()){
return true;
} else {
$this->form_validation->set_message('validate_credentials','Incorrect username/password');
return false;
}
}