Welcome Guest, Not a member yet? Register   Sign In
details not being pull from databse table user login
#11

[eluser]Dam1an[/eluser]
Yes, that would appear to be the case
Having a return statement in the middle of a function will cause the function to end at that point

(the reason you're using the return is cause you tried to embed the function TheFuzzyOne gave you into inline code)

Try changing it to an if statement
#12

[eluser]learning_php[/eluser]
do you mean somthing like this:
Code:
if( $res = $this->db->get_where('members', array('username' => $username, 'password' => $password)))
       {
        return ($res->num_rows() == 1);
           }
#13

[eluser]Dam1an[/eluser]
Try this
Code:
function process_login() {
        $username = $this->input->post("username");
        $password = $this->input->post("password");
        
        $this->db->where('username', $username);
        $this->db->where('password', $password);
        $query = $this->db->get('members');
        
        if($query->num_rows() == 1) {
            $data = array('username'=>$username,'logged_in'=>true);
            $this->session->set_userdata($data);
            redirect('dashboard');
        } else{
                $this->session->set_flashdata('message','<div id="message">you have entered the wrong details</div>');
            redirect('login/index');
        }
    }

All I've done, is broken the where and get into seperate clauses (personal preference)
And checked if that returns a single row, if it does, log them in as normal, else, redirect to login
#14

[eluser]learning_php[/eluser]
Hi,

It works perfectly thank you very much this has been bugging me for a few days.

Thanks again
#15

[eluser]Dam1an[/eluser]
Your welcome Smile
Now all you need to do (if you want to do proper MVC) is move the database stuff to a model




Theme © iAndrew 2016 - Forum software by © MyBB