10-11-2012, 02:23 PM
[eluser]RalphLeMouf[/eluser]
I'm really close but the errors I tried to add via is not correct. So should I make that from scratch or is there a code-igniter shortcut for that?
This is what I ended up with:
I'm really close but the errors I tried to add via
Code:
echo validation_error();
This is what I ended up with:
Code:
function validate_credentials_login()
{
$this->load->library('session');
$this->load->helper(array('form','url'));
$this->load->model('user_model', 'um');
$this->load->library('encrypt');
$this->load->library('form_validation');
$this->form_validation->set_rules('email_login', 'Email', 'trim|required|valid_email');
$this->form_validation->set_rules('password_login', 'Password', 'trim|required');
if ( $this->form_validation->run() === TRUE )
{
$user = $this->um->validate_home_login(array('email' => $this->input->post('email_login')));
if ( $user )
{
if ( $user->password == $this->encrypt->sha1( $user->salt . $this->encrypt->sha1($this->input->post('password_login'))) && $user->email == $this->input->post('email_login') )
{
$this->session->set_userdata(array('email' => $this->input->post('email_login')));
redirect('account/edit');
}
else
{
echo validation_error();
}
}
else
{
echo validation_error();
}
}