Quantcast
Channel: Active questions tagged return-value - Stack Overflow
Viewing all articles
Browse latest Browse all 210

Why does this CodeIgniter controller method always redirect after calling the model method?

$
0
0

I'm building a log in for my website. I have this if statement:

$application = 'home';$this->user_model->loggedin() == TRUE || redirect($application);$rules = $this->user_model->_rules;$this->form_validation->set_rules($rules);if ($this->form_validation->run() !== FALSE) {    if ($this->user_model->login() !== FALSE) {        redirect('home');        echo 'success';    }  else {        echo 'fail';     }}

For some reason it dose not run the else when I present with the condition == FALSE which would be entering wrong email and password. either way I get the message success am I missing something here?

Here is the function login in user_model if it helps.

public function login() {    $user = $this->get_by(array('email_address' => $this->input->post('email_address'),'password' => $this->hash($this->input->post('password'))            ), TRUE);    if (count($user)) {        // log in user        $data = array('first_name' => $user->first_name,'last_name' => $user->last_name,'email_address' => $user->email_address,'id' => $user->id,'loggedin' => TRUE,        );      $this->session->set_userdata($data);       }}

Viewing all articles
Browse latest Browse all 210

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>