Welcome Guest, Not a member yet? Register   Sign In
help with login
#1

[eluser]dadamssg[/eluser]
So im trying to validate a simple login form. I'm trying to check if the username and password were found in my database. I don't know how to grab the cleaned password into my username_check function though. How do i assign that?

my controller
Code:
<?php

class Login extends Controller {

    function Login()
    {
        parent::Controller();
        $this->load->helper('url');
        $this->load->helper('form');
        
    }

    function index()
    {
        $this->load->helper(array('form', 'url'));
        $this->load->library('form_validation');
        
        $this->form_validation->set_rules('username', 'Username', 'trim|required|callback_username_check|xss_clean');
        $this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean');
        
        if ($this->form_validation->run() == FALSE)
        {
            $this->load->view('login_view');
        }
        else
        {
            $this->load->view('login_view');
        }
        
        
        function username_check($user, $pass)
        {
            $query = $this->db->query("SELECT loginName,active FROM Member WHERE loginName='$user'
                                AND password=md5('$pass')");
                if($query->result()->num_rows() > 0)
                {
                return TRUE;
                }
                else
                {
                return FALSE;
                }
        
        }
    
    
}

?>
and my login_view
Code:
<?php

echo validation_errors();

echo form_open('login');
?>
<p>&lt;input type='text' name='username' /&gt;&lt;/p>
<p>&lt;input type='password' name='password' /&gt;&lt;/p>
<p>&lt;input type='submit' value='Submit' /&gt;&lt;/p>
&lt;/form&gt;


Messages In This Thread
help with login - by El Forum - 01-08-2010, 11:18 PM
help with login - by El Forum - 01-08-2010, 11:35 PM
help with login - by El Forum - 02-14-2010, 12:59 PM
help with login - by El Forum - 02-14-2010, 01:11 PM



Theme © iAndrew 2016 - Forum software by © MyBB