php - CI - show me what went wrong -


this question exact duplicate of:

i've developed simple login system works ok fails, , need know why.

question: how show causing fail?

here's database function:

function login($email,$password) {     $this->db->where("email",$email);     $this->db->where("password",$password);      $query=$this->db->get("users");     if($query->num_rows()>0)     {         foreach($query->result() $rows)         {             //add data session             $newdata = array(                 'user_id'  => $rows->id,                 'user_name'  => $rows->username,                 'user_email'    => $rows->email,                 'logged_in'  => true,             );         }         $this->session->set_userdata($newdata);         return true;     }     return false; } 

and here's logic:

public function login() {     $this->load->library('form_validation');     // field name, error message, validation rules     $this->form_validation->set_rules('email', 'your email', 'trim|required|valid_email');     $this->form_validation->set_rules('password', 'password', 'trim|required|min_length[4]|max_length[32]');      if($this->form_validation->run() == false)     {         $this->signin();     }     else     {         $email=$this->input->post('email');         $password=md5($this->input->post('pass'));         $result=$this->user_model->login($email,$password);         if($result)         {             $this->dash();         }         else         {             $data['title']= 'login error';             $this->load->view('nav/header', $data);             $this->load->view('login', $data);             $this->load->view('nav/footer', $data);         }     } } 

i know error happening redirect login page if fails , change title text show me (only in testing mode right now). how can find out going wrong?

this check database function:

function login($email,$password) {     $this->db->where("email",$email);     $this->db->where("password",$password);      $query=$this->db->get("users");     if($query->num_rows()>0)     {         foreach($query->result() $rows)         {             //add data session             $newdata = array(                 'user_id'  => $rows->id,                 'user_name'  => $rows->username,                 'user_email'    => $rows->email,                 'logged_in'  => true,             );         }         $this->session->set_userdata($newdata);         return true;     }     return false; } 

i assume php code fine, need set custom form-validation-message each input know input went wrong , echo them:

<?php echo validation_errors(); ?> 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -