[eluser]Unknown[/eluser]
I have just implemented a login script and it doesn't seem to work i dont not know it seems to be going wrong in the code
i've got my login controller which does the following
login.php
Code:
class login extends CI_Controller {
function index(){
$data['maincontent'] = 'login_form';
$this->load->view('includes/template', $data);
}
function validate_credentials(){
$this->load->model('membership_model');
$query = $this->membership_model->validate();
if($query){
$data = array(
'username' => $this->input->post('username'),
'is_logged_in' => true
);
$this->session->set_userdata($data);
redirect(site/members_area);
}
else{
$this->index();
}
}
}
i've my model which accesses the database with no problems
membership_model.php
Code:
class Membership_model extends CI_Model {
function validate(){
$query = $this->db->get("membership");
//retrieve all records where username equals to typed in username value
//retrieve all records where password equals to typed in password value
$this->db->where('username', $this->input->post('username'));
$this->db->where('password', md5($this->input->post('password')));
if($query->num_rows == 1){
return true;
}
}
my config folder has got the following
details
config.php
Code:
$config['base_url'] = 'http://localhost/ci_demo';
$config['encryption_key'] = 'sholly';
autoload.php
Code:
$autoload['model'] = array('membership_model');
$autoload['helper'] = array('url', 'form');
$autoload['libraries'] = array('database', 'session');
route.php
Code:
$route['default_controller'] = "login";
Any help please