Jump to content

Why Can't Registered Users Within My Membership Table Not Log Into My System


Jimbird85

Recommended Posts

Hi there i have several users created in my membership db table but since I added in my validateUsers function to my controller to make sure non registered users cannot sign into my site, registered users cannot log in either. Why is this?

 

Controller:

 

 

class Login extends CI_Controller

{

function Login()

{

parent::__construct();

$this->load->model('membership');

}

 

 

 

function loguserin()

 

{

 

$this->load->helper(array('form', 'url'));

 

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

 

$this->form_validation->set_rules('username', 'Username', 'required|min_length[4]|max_length[12]|callback_validateUser|trim');

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

 

 

$username = $this->input->post('username');

$password = $this->input->post('password');

 

 

 

if ($this->form_validation->run())

{

$this->validateUser($username, $password);

$this->session->set_userdata('status', 'OK');

$this->session->set_userdata('username', $username);

 

redirect('home');

}

else

{

$this->session->set_userdata('status', 'NOT_OK');

$this->load->view('shared/header');

$this->load->view('account/logintitle');

$this->load->view('account/loginview');

$this->load->view('shared/footer');

}

}

 

 

function validateUser($username, $password)

{

$this->db->select('*')->from('membership');

$this->db->where('username', $username);

$this->db->where('password',MD5($password));

$query = $this->db->get();

if ($query ->num_rows ==1)

{

return true;

}

 

else

{

var_dump($username, $password);// this only seems to throw back the username, not the password, don't know why

$this->form_validation->set_message('validateUser', 'Invalid username/password');

return false;

}

 

}

 

function index()

{

$this->load->view('shared/header');

$this->load->view('account/logintitle');

$this->load->view('account/loginview');

$this->load->view('shared/footer');

}

 

Thanks for the help

Edited by Jimbird85
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.