Welcome Guest, Not a member yet? Register   Sign In
What view should I load if the validation fails?
#1

[eluser]tommo.wilson[/eluser]
Hi all,

This is probably a very simple question, but I'm brand new to CI and I'm getting stuck.

I want my website to have a new user registration form and also a login form. I want the login form to be displayed on every page.

Look at the code below. This is the controller that is called after clicking my login submit button. Keep in mind this could be submitted from any page. ie. home, registration, about us etc.

Code:
class Login extends Controller {
    
    function index()
    {
        $this->load->helper(array('form', 'url'));
        
        $this->load->library('form_validation');
            
        $this->form_validation->set_rules('username', 'Username', 'required');
        $this->form_validation->set_rules('password', 'Password', 'required');
            
        if ($this->form_validation->run() == FALSE)
        {
            $this->load->view('XXXXX');
        }
        else
        {
            $this->load->view('login_success');
        }
    }
}

My question is what do I put where it says XXXXXX? How do I know which view to load if the validation fails? I can't put something static in there like "registration" because if the user tries to login on the about us page and the login fails they will be redirected to the registration page. It would look weird and be confusing.

Thanks in advance guys
Tom


Messages In This Thread
What view should I load if the validation fails? - by El Forum - 01-12-2010, 05:19 AM
What view should I load if the validation fails? - by El Forum - 01-12-2010, 05:39 AM
What view should I load if the validation fails? - by El Forum - 01-12-2010, 03:29 PM
What view should I load if the validation fails? - by El Forum - 01-12-2010, 04:24 PM
What view should I load if the validation fails? - by El Forum - 01-12-2010, 05:06 PM



Theme © iAndrew 2016 - Forum software by © MyBB