Welcome Guest, Not a member yet? Register   Sign In
Login System, help?
#1

[eluser]Declan[/eluser]
Hello CI forums,

I've been looking at a lot into codeigniter lately and recently decided to build something with it. I started with the login system, and I'm having trouble. Here's my code:

Login Controller:
Code:
<?

class Login extends Controller{
    
    function index()
    {
        $this->load->view('login');
    }
    
    function validate_login()
    {
        
        $this->load->model('membership_model');
        $query = $this->membership_model->validate();    
        
        if ($query)
        {
            $data['username']         = $this->input->post('username');
            $data['is_logged_in']     = true;            
            $this->session->set_userdata($data);
            
            redirect('navigate/online');
        }
        else
        {
            $this->index();
        }
        
        
    }
}

Login Model:
Code:
<?

class Membership_model extends Model{
    
    function validate()
    {
        $this->db->where('username', $this->input->post('username'));
        $this->db->where('password', sha1($this->input->post('password')));
        $query = $this->db->get('users');
        
        if ($query->num_rows == 1)
        {
            return true;
        }
    }

}

?>

Login View:
Code:
<?
    
    echo form_open('login/validate_login');
    echo form_input('username', 'Username');
    echo form_password('password', 'Password');
    echo form_submit('submit', 'Login');


?>


My problem is that when I click login it takes me to "login/validate_login", but gives me a 404.
All help is greatly appreciated.
:cheese:

Thanks, Declan.


Messages In This Thread
Login System, help? - by El Forum - 01-22-2010, 04:50 PM
Login System, help? - by El Forum - 01-22-2010, 05:02 PM
Login System, help? - by El Forum - 01-22-2010, 05:07 PM
Login System, help? - by El Forum - 01-22-2010, 08:05 PM
Login System, help? - by El Forum - 01-23-2010, 02:38 AM
Login System, help? - by El Forum - 01-23-2010, 11:00 AM
Login System, help? - by El Forum - 01-23-2010, 07:40 PM
Login System, help? - by El Forum - 01-23-2010, 09:34 PM
Login System, help? - by El Forum - 01-23-2010, 09:40 PM



Theme © iAndrew 2016 - Forum software by © MyBB