当我通过注册控制器使用加密的密码插入数据时,已插入此数据。但是,当我登录时说密码错误。我的注册控制器代码是:
$encrypted_password = $this->encryption->encrypt($this->input- >post('user_password'));
登录模型代码为:
<?php
class Login_model extends CI_Model{
function can_login($email, $password)
{
$this->db->where('User_email' , $email);
$query = $this->db->get('tbl_user');
if($query->num_rows() > 0){
foreach($query->result() as $row){
if($row->is_email_verified == 'yes'){
$store_password = $this->encryption->decrypt($row->User_password);
if($password == $store_password)
{
$this->session->set_userdata('id', $row->id);
}
else
{
return 'Worng Password';
}
}
else
{
return 'First verified your email address';
}
}
}
else
{
return 'Wrong Email Address';
}
}
}
希望这一点对您有所帮助。...
<?php
class Login_model extends CI_Model{
function can_login($email, $password)
{
$this->db->where('User_email' , $email);
$query = $this->db->get('tbl_user');
if($query->num_rows() > 0){
foreach($query->result() as $row){
if($row->is_email_verified == 'yes'){
$store_password = $row->User_password;
$current_password = $this->encryption->encrypt($password);
if($current_password == $store_password)
{
$this->session->set_userdata('id', $row->id);
}
else
{
return 'Worng Password';
}
}
else
{
return 'First verified your email address';
}
}
}
else
{
return 'Wrong Email Address';
}
}
}