• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI session not working properly

#6
[eluser]manash007[/eluser]
This is my Login function:
Code:
function login(){
        $header_data=array();
        $this->load->model('headmodel');
        $header_data=$this->headmodel->getHeaderData();
        $output=$this->load->view('header',$header_data,true);        
        
    
        
        if($this->input->post('submit')){
            //var_dump($this->input->post('password'));
            $this->load->library('validation');
          
            $rules['username'] = 'trim|required|callback_checklogin';
            $rules['password'] = 'trim|required';
            $this->validation->set_rules($rules);

            $fields['username']   = 'User Name';
            $fields['password']  = 'Password';

            $this->validation->set_fields($fields);
            if($this->validation->run()==FALSE){
        
                $output.=$this->load->view('user/user_login',$header_data,true);
            }else{                
                
                $output.=$this->load->view('user/user_nav',$header_data,true);        
                $output.=$this->load->view('user/user_account',$header_data,true);
                
            }
        }else{

        $output.=$this->load->view('user/user_login',$header_data,true);
        }        
        $output.=$this->load->view('footer',$header_data,true);
        $this->output->set_output($output);
        }

And my callback function is:::::

function checklogin(){
        $uname = $this->input->post('username');
        $pass = $this->input->post('password');
        $password = md5($pass);
        
        $this->db->where('username',$uname);
        $this->db->where('password',$password);
        $query = $this->db->get('user');
        
        if($query->num_rows()){
            $user = $query->result();
            $this->session->set_userdata('user',$user);
            return true;
        }else{
            $this->validation->set_message('checklogin','User Name and Password do not match');
            return false;
        }
    }


Messages In This Thread
CI session not working properly - by El Forum - 04-11-2008, 10:30 PM
CI session not working properly - by El Forum - 04-12-2008, 11:25 AM
CI session not working properly - by El Forum - 04-12-2008, 03:46 PM
CI session not working properly - by El Forum - 04-12-2008, 09:10 PM
CI session not working properly - by El Forum - 04-12-2008, 09:36 PM
CI session not working properly - by El Forum - 04-12-2008, 09:40 PM
CI session not working properly - by El Forum - 04-12-2008, 09:42 PM
CI session not working properly - by El Forum - 04-12-2008, 09:46 PM
CI session not working properly - by El Forum - 04-13-2008, 06:29 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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