I am trying to use the sha1 to verify the password that is encrypted in the database using the same procedure. It does not give an error and it does not do anything as well. I presume I am doing something wrong which I do not know.
Model
function check_login ($email, $password) {
$this->load->database();
// Query to retrieve the user's details
// based on the received username and password
$sha_password = sha1($password);
$this->db->from('user');
$this->db->where('email', $email);
$this->db->where('password', $sha_password);
$q = $this->db->get()->result();
// The results of the query are stored in $q.
// If a value exists, then the user account exists and is validated
if (is_array($q) && count($q) == 1) {
// Set the users details into the $details property of this class
$this->details = $q[0];
// Call set_session to set the user's session
$this->set_session();
return true;
}
return false;
}
Controller
public function login() {
$this->form_validation->set_rules('email', 'Email', 'trim|required|xss_clean');
$this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean');
if ($this->form_validation->run() == FALSE) {
// return main page if submitted form is invalid.
$this->load->view('abt_login');
} else {
$email = $this->input->post('email');
$password = $this->input->post('password');
$this->load->model('abt_db');
$q = $this->abt_db->check_login($email, $password);
if ($q) {
// $this->abt_db->set_session($q);
redirect('index.php/abovetheblues/abt_abovetheblues');
} else {
$this->show_login(true);
}
}
}