Welcome Guest, Not a member yet? Register   Sign In
New to Codeigniter Error issue with Login and Register code
#5

(03-25-2016, 11:00 AM)ossieboy Wrote:
(03-25-2016, 09:45 AM)Rhyno_xD Wrote: did you extend CI_Model class also post the code here.

class model_users extends CI_Model{


public function __construct() 
     
           parent::__construct(); 
           $this->load->database();

public function can_log_in(){

$this->db->where('email',$this->input->post('email'));
$this->db->where('password',md5($this->input->post('password')));
$query = $this->db->get('user');

if ($query->num_rows()== 1){

return true;

}else{
return false;
}
}
}


Yes I did extend the CI 
The problem seems to be in the file below with the callback function :

Maiin.php

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');


class Main extends CI_Controller {


public function index(){
$this->login();
}

public function login(){ 
$this->load->view('login');
}

public function members(){
$this->load->view('members');

}

public function login_validation(){

$this->load->library('form_validation');

$this->form_validation->set_rules('email', 'Email','required|trim|callback_validate_credentials'); 
$this->form_validation->set_rules('password', 'Password','required|trim');  



if ($this->form_validation->run()){
redirect('main/members');
}else{
$this->load->view('login');
}
}

public function validate_credentials (){
$this->load->model('model_users');

if ($this->model_users->can_log_in()){
return true;


}else{

$this->form_validation->set_message('validate_credentials','incorrect username/password.');

return false;
}


}

}

Reply


Messages In This Thread
RE: New to Codeigniter Error issue with Login and Register code - by ossieboy - 03-28-2016, 11:58 PM



Theme © iAndrew 2016 - Forum software by © MyBB