0
我有問題登錄一個user.I在database.Now md5
方法保存在加密的密碼時,我想選擇使用加密密碼錶單數據庫中的用戶返回null。從數據庫中選擇加密密碼笨
這是我的代碼:
控制器:
function login(){
$username=$this->input->post('username');
$password=$this->input->post('password');
$user=$this->mymodel->login($username,$password);
if($user)
$this->load->view('home');
else
echo "The user name or password is wrong";
}
型號:
function login($username,$password){
$where=array('username'=>$username,'password'=>md5($password));
$this->db->select()->from('user')->where($where);
$query=$this->db->get();
return $query->first_row('array');
}
但此查詢返回null;
'$這個 - > DB->獲得()'將是一個函數的調用。該代碼中還有一個語法錯誤。在first_row()後面有一個額外的右括號和撇號。 – BrightIntelDusk
用於在codeigniter中調試查詢的一些非常有用的東西是'echo $ this-> db-> last_query();' – BrightIntelDusk
@ IntegrityFirst.sorry這些錯誤來自我在這裏輸入的內容,而不是我工作的代碼,現在我糾正它。 – setara