我使用phpass在Insert上散列我的密码,如下所示
public function addAdmin(){
$this->load->library('phpass');
$this->load->database();
$psw = 'admin1234';
$hashed = $this->phpass->hash($psw);
$now = date("Y-m-d H:i:s");
$data = array(
'userid' => 'admin_user' ,
'userfname' => 'Admin' ,
'userlname' => 'Admin',
'userdname' => 'Admin' ,
'useraddress' => '20/72,Vidarshana Mawatha, Galawilawatta, Homagama' ,
'usercountry' => 'Sri Lanka',
'usercontactno' => '0112-892199' ,
'userlastlog' => $now ,
'userpassword' => $hashed ,
'userpermission' => '1',
'useremail' => 'dilukshanmahendra@gmail.com'
);
$this->db->insert('ecom-user', $data);
echo "Successfully Added!";
}
但是当我输入相同的用户ID和密码(正确的用户名和密码)在登录验证时通过将它们与存储的密码进行匹配,对于以下我所指示的“1”
,它返回“0”public function validateLogin($userid,$userpass){
$this->load->library('phpass');
$this->load->database();
$hashed = $this->phpass->hash($userpass);
$this->db->select('*');
$this->db->from('ecom-user');
$this->db->where('userid', $userid);
$this->db->where('userpassword', $hashed);
$result = $this->db->get();
echo $this->db->last_query();
echo '<br/>'.$result->num_rows();
}
请有人帮我解决这个问题