Welcome Guest, Not a member yet? Register   Sign In
Help creating retrieving session data from database needed pwetty pwease
#1

[eluser]Tom Taila[/eluser]
Ok let me start by saying sory for the long wounded explanation which follows :
so i have a login and logout function which work fine except for my login function i would like to display info about the user which is stored in my database table which is called 'members'. i know how to display it and start a session but i aint sure on how to pull the data from the database to store it in an array which can be used later whilst the user is logged in, ok so heres two codes that i have so far


this is from my model called "membership_model"
Code:
function login_validation() {
        $this->db->where('email', $this->input->post('email'));
        $this->db->where('password', md5($this->input->post('password')));
        $query = $this->db->get('members');
        
        if($query->num_rows == 1){
            return true;
        }
        
    }

and this is from my controller called "login"

Code:
function login_validation() {
        $this->load->model('membership_model');
        $query = $this->membership_model->login_validation();
        
        if($query) {
            $data = array(
                    'email' => $this->input->post('email'),
                    'is_logged_in' => true
            );
            
            $this->session->set_userdata($data);
            redirect('main');
        }
        
        else {
            $this->load->view('main_page');
        }
    }
    
    function logout() {
        $this->session->sess_destroy();
        redirect('main');
    }
}

thanks peoples Smile hope u guys can help this poor lil nooblet lol


Messages In This Thread
Help creating retrieving session data from database needed pwetty pwease - by El Forum - 05-13-2010, 04:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB