php - CI 3 operation for user auth w/out model file -


i've revised code after following tutorials, i'm still stuck , appreciate guidance on how fix using view , controller.

view:

 <form name='checklogin' action='<?php echo base_url();?>/index.php/myform/checklogin' method='post'>   <input type="text" name='username' id='username' class="form-control" placeholder="username" style='height: 3em;'><br>   <input type="password" name='password' id='password' class="form-control" style='height: 3em;' placeholder="password" required><br>   <center><button class="btn draw-border" type="submit" >sign in</button></center>   <center><br><a href= "/ci/index.php/myform/<?php echo "userregistration";?>">register</a></center>  </form> 

controller:

public function showlogin(){      $this->load->view('loginview');  }     // check login data   public function checklogin() {      $this->form_validation->set_rules('username', 'username', 'required');     $this->form_validation->set_rules('password', 'password', 'required|md5|callback_check_database');          if ($this->form_validation->run() == false) {             $this->load->view('loginview');         } else {             redirect("/myform/successmessage");         } }  public function check_database($user_password){     $user = $this->input->post('username');     $pass = $this->input->post('password');      $result = $this->user->login($user, $pass);      if ($result) {         $query = array();         foreach($result $row) {             $query = array(                 'id' => $row->id,                 'username' => $row->user_name             );         }         return true;     }     else {         $this->form_validation->set_message('check_database', 'invalid username or password');         return false;      }  } 

the names of 2 table rows, besides id, in mysql, 'user_name' , 'user_password'.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -