出於某種原因,用戶可以使用任何密碼登錄,開始我還以爲我忘了檢查密碼,但我沒有......我只是不能找到問題笨:驗證問題
這裏是型號:
/*#######################################################*/
function validate()
/*#######################################################*/
{
$this->db->where('username', $this->input->post('username'));
$this->db->where('password', md5($this->input->post('password')));
$q = $this->db->get('user_extra');
if($q->num_rows() == 1):
return true;
else:
return false;
endif;
}//end of function validate()
/*#######################################################*/
function validate_credentials()
/*#######################################################*/
{
$this->load->model('membership_model');
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Name', 'trim|required');
$this->form_validation->set_rules('password', 'password', 'trim|required');
if(!$this->membership_model->validate()):
$this->form_validation->set_message('check_login', 'Login not correct, please try again.');
endif;
if($this->form_validation->run() == FALSE):
$this->index();
else:
$this->membership_model->userinfo($this->input->post('username'));
//should redirect to last view
redirect($this->session->flashdata('redirect_url'));
endif;
}// end of validate_credentials()
callback_validaion [密碼]在set_rules和你的名字控制器函數validate(),它應該驗證()??? 無論如何,我試過,但你只傳遞密碼,你確定它會找到用戶名?除了在控制器中添加查詢外,它應該位於模型中。但謝謝你的迴應 – Christophe 2010-06-10 09:56:13
哦,對於我以前的評論抱歉,我明白你的意思,我的壞。 – Christophe 2010-06-10 09:59:27