User Login

#21
[eluser]clip[/eluser]
try changing this...
Code:
if ($checkUser == FALSE) {
            
            echo 'Password is incorrect.';
            
        }else{
           ....................
to
Code:
if ($checkUser->num_rows() < 1) {
            
            echo 'Password is incorrect.';
            
        }else{
again this is in the link I suggested you read about generating query results.

Edit: It appears it isn't being checked because get_where() returns an array of objects regardless of the number of rows fetched by your query.

#22
[eluser]GamingFusion[/eluser]
ok something is wrong im being redirected to the home page but none of the variables work

Code:
function login()
    {
        $this->load->helper('cookie');    
    
        $username = $this->input->post('username');
        $password =  $this->input->post('password');
        
        $checkUser = $this->db->get_where('users', array('username' => $username, 'password' => $password));
        
        if ($checkUser->num_rows() < 1) {
            
            echo 'Password is incorrect.';
            echo $password;
            
        }else{
                      $cookie = array(
                   'username'   => $username,
                   'passdword'  => $password,
                   );

                set_cookie($cookie);
                
                redirect('theater', 'refresh');
        
        }        
    }


the login page directs me to the home like it should if the variables have values

heres the checkLogin() function
Code:
function checkLogin()
    {
    
        $this->load->helper('cookie');
            
        $u1 = get_cookie('username');
        $p1 = get_cookie('password');
        
        
        $logged = $this->db->get_where('users', array ('username' => $u1, 'password' => $p1));

        if($logged->num_rows() >0)
        {
             $row = $logged->row();

             $uId = $row->id;
             $uName = $row->username;
            
            $data['uId'] = $uId;
            $data['uName'] = $uName;
            
            echo $u1;
            
            return $row;
        }
    }

what i changed in here was

$query = $this->db->get_where('users', array ('username' => $u1, 'password' => $p1));

to

$logged = $this->db->get_where('users', array ('username' => $u1, 'password' => $p1));


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.