Okay, so for this login example you'll need the the Form Helper, the Form Validation Class and the URL Helper.
class Login extends MY_controller {
function index()
{
$this->load->helper('url');
$this->load->helper('form');
$this->load->library('form_validation');
// some simple rules
$this->form_validation->set_rules('username', 'Username', 'required|alpha_dash|max_length[30]');
$this->form_validation->set_rules('password', 'Password', 'required');
if ($this->form_validation->run() == FALSE) {
// This will be the default when the hit this controller/action, or if they submit the form and it does not validate against the rules set above.
// Build your form here
// Send it to a login view or something
} else {
// The form has been submitted, and validated
// At this point you authenticate the user!!
if ($userIsAuthenticated) {
redirect('controller/action'); //anywhere you want them to go!
} else {
// not authenticated...in this case show the login view with "bad username/password" message
}
}
}
tl;dr
Use the redirect() fuction in the URL Helper to send the user to other pages based on logic in your controller.