[eluser]austintbiggs[/eluser]
No matter what I do I can't seem to get the Ion Auth errors to display although I believe me issue lies in standard php and codeigniter. Anyone have ideas?
in the controller
Code:
function login()
{
$this->data['title'] = "Login";
//validate form input
$this->form_validation->set_rules('email', 'Email Address', 'required|valid_email');
$this->form_validation->set_rules('password', 'Password', 'required');
if ($this->form_validation->run() == true)
{ //check to see if the user is logging in
//check for "remember me"
$remember = (bool) $this->input->post('remember');
if ($this->ion_auth->login($this->input->post('email'), $this->input->post('password'), $remember))
{ //if the login is successful
//redirect them back to the home page
$this->session->set_flashdata('message', $this->ion_auth->messages());
redirect($this->config->item('base_url'), 'refresh');
}
else
{ //if the login was un-successful
//redirect them back to the login page
$this->session->set_flashdata('message', $this->ion_auth->errors());
redirect('login', 'refresh'); //use redirects instead of loading views for compatibility with MY_Controller libraries
}
}
else
{ //the user is not logging in so display the login page
//set the flash data error message if there is one
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
$this->data['email'] = array('name' => 'email',
'id' => 'email',
'type' => 'text',
'value' => $this->form_validation->set_value('email'),
);
$this->data['password'] = array('name' => 'password',
'id' => 'password',
'type' => 'password',
);
$this->load->view('body/login', $this->data);
}
}
within the view
Code:
<div id="infoMessage"><?php echo $message;?></div>
<?php $email = array('class' => 'indent round_all'); $password = $email;
echo form_open('body/login'); ?>
<label class="fields"><strong>Username</strong>
<?php echo form_input($email);?></label>
<label class="fields"><strong>Password</strong>
<?php echo form_password($password);?></label>
<button class="button_colour round_all" type="submit"><img width="24" height="24" alt="Locked 2" src="../beauty/images/body/icons/small/white/Locked 2.png"><span>Login</span></button>
<div id="bar" class="round_bottom">
<label><?php echo form_checkbox('remember', '1', FALSE);?>Auto-login in future.</label>
<a href="#">Forgot your password?</a>
</div>
<?php echo form_close();?>
</div>