[eluser]Tom Taila[/eluser]
wow thanks a lot guys, the problems fixed and now i can display the users data! i was stuck for ages and im going to post my fixed code as i know its frustrating when people get a fix and never give thanks and conclude the problem to the people who helped em in the first place:
Code:
function login_validation() {
$this->load->model('membership_model');
$query = $this->membership_model->login_validation();
$this->db->where('email', $this->input->post('email')); //this line checks against what the user input as an email and filters out the results in the database
$this->db->where('password', md5($this->input->post('password'))); //this line checks against what the user input as a password and filters out the results in the database
$database_row = $this->db->get('members'); //this then retrieves the rows filtered by the two above statements
$result = $database_row->row(); //this is like the result() method but is used when only one row is in question/ being retrieved
if($query) { //if $query is true or runs without errors
$data = array( //assigns values to the variable '$data'
'email' => $this->input->post('email'),
'first_name' => $result->first_name,
'last_name' => $result->last_name,
'full_name' => "$result->first_name" . " $result->last_name",
'is_logged_in' => true
);
$this->session->set_userdata($data); //passes the variable '$data' to the set_userdata() method and hence the sessions userdata is set
redirect('main'); //redirects us back to the main function
}
else {
$this->load->view('main_page'); //else if $query is not true or doesnt run the main_page view is loaded
}
}
thanks again :)