我最近创建了一个注册页面,用户可以在其中注册并创建自己的帐户。但是如果我退出然后重新进入帐户并尝试登录,则只接受加密版本的密码。如何让我的 loguserin 函数与我的数据库对话并让它明白它实际上是用户最初输入的普通密码?
控制器:
function loguserin()
{
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'required|min_length[4]|max_length[12]|callback_validateUser|trim');
$this->form_validation->set_rules('password', 'Password', 'required|md5|trim');
if ($this->form_validation->run())
{
$username = $this->input->post('username');
$password = $this->input->post('password');
$this->session->set_userdata('status', 'OK');
$this->session->set_userdata('username', $username);
redirect('home');
}
else
{
$this->session->set_userdata('status', 'NOT_OK');
$this->load->view('shared/header');
$this->load->view('account/logintitle');
$this->load->view('account/loginview');
$this->load->view('shared/footer');
}
}
function validateUser($username, $password)
{
$this->db->select('*')->from('membership');
$this->db->where('username', $username);
$this->db->where('password',MD5($password));
$query = $this->db->get();
if ($query ->num_rows ==1)
{
$this->form_validation->set_message('validateUser', 'Invalid username/password');
return false;
}
else{
return true;
}
}