[eluser]RalphLeMouf[/eluser]
Hello -
I have a login form that requires email and password. When I submit the form with both fields empty, the proper error messages appear, however when I put a CORRECT email address and a INCORRECT password, "invalid email" error pops up and no error displays for the password.
So basically the only time I can get "invalid password" is when I submit the form empty.
Here is my view(form):
Code:
<?php
echo form_open('auth/validate_credentials_login');
echo "<span class='errors_login'>";
echo form_error('email_login');
echo "</span>";
echo form_label('','Email', 'email_login');
$data = array( 'name' => 'email', 'class' => 'input', 'placeholder' => 'Email');
echo form_input($data, set_value('email_login'));
echo "<span class='errors_login'>";
echo form_error('password_login');
echo "</span>";
echo form_label('', 'Password', 'password_login');
$data = array( 'name' => 'password_login', 'class' => 'input', 'placeholder' => 'Password');
echo form_password($data, set_value('sha1(password_login)'));
echo form_submit('submit_login', 'Login');
echo form_close();
?>
and here is my controller:
Code:
function validate_credentials_login()
{
// WHEN THE VIEW IS LOADED THIS FUNCTION IS CALLED AND LOADS MODEL AS WELL AS DEFINES THE SALT VARIABLE AND LOADS THE ENCRYPTING HELPER LIBRARY
$this->load->library('encrypt');
$this->load->helper('url');
$this->load->library('form_validation');
$this->form_validation->set_rules('email_login', 'Email', 'required|is_unique[users.email]');
$this->form_validation->set_rules('password_login', 'Password', 'required');
$this->load->library('session');
$this->load->model('user_model', 'um');
$login = $this->input->post('submit_login');
if($login) {
$user = $this->um->validate_home_login(array('email' => $this->input->post('email_login')));
if( $user ) {
// CHECK THE USER'S PASSWORD AGAINST THE ONE FROM THE LOGIN FORM
if($user->password == $this->encrypt->sha1( $user->salt . $this->encrypt->sha1($this->input->post('password_login')))) {
$this->session->set_userdata(array(
'email' => $this->input->post('email_login')
));
redirect('account/dashboard');
exit;
}
}
}
if($this->form_validation->run() == FALSE){
$data['main_content'] = 'home/home_page';
$this->load->view('includes/templates/home_page_template', $data);
}
}
any help is greatly appreciated. Thanks in advance.