• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to validate user's login?

#1
[eluser]Tony W[/eluser]
I used the form helper to generate a form for login including the username and password fields.

In my function, I used the following to catch the submitted info:

Code:
$username = $this->input->post('username', TRUE);
    $password = $this->input->post('password', TRUE);

I wonder how to validate the username and password (to compare with the usernames and passwords in mysql database).

Can I use this db query?
Code:
$this->db->where('username', $username);

#2
[eluser]charlie spider[/eluser]
check out the validation class here:

http://ellislab.com/codeigniter/user-gui...ation.html

you will be able to add standard validation rules like "required" or check that a password entered in twice matches itself.

if you want to check whether a new username is already in use, you can create a callback function to retrieve existing usernames from your db and compare them to the new username

but if you just want to check that an existing username and password are legit, then i would recommend checking out one of the many authorization libraries like FreakAuth or ReduxAuth or Simple Auth. Those will take care of all of your login needs depending on which one you choose.

#3
[eluser]Tony W[/eluser]
thanks Charlie. I didn't realize there are so many libraries freely available. Smile


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.