我遇到以下代碼的問題。我希望用戶使用他們的用戶名或電子郵件登錄。當我使用用戶名時,它工作得很好,但是當我使用電子郵件時,即使密碼錯誤,我也可以登錄。在codeigniter中使用電子郵件地址或用戶名登錄
public function can_login(){
$user_mail = $this->input->post('user_mail');
$this->db->where('email =', $user_mail);
$this->db->or_where('username =', $user_mail);
$this->db->where('password',md5($this->input->post('password')));
$this->db->where('status =', 'registered');
$query=$this->db->get('user');
if($query->num_rows()== 1) {
return true;
} else {
return false;
}
}
只是試圖從你的活動記錄 –
刪除等號(=)這是你需要什麼,我不想把它作爲,因爲它已經寫得太好了這裏的答案:HTTP://計算器。 com/questions/7512116/codeigniter-activerecord-where-statement-issue –