RE: Passwords

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Ben,

> I have created a user login/registration page.  As of now I 
> am using a MySQL database to store the info of the user.  To 
> validate the user I also have the password stored in the same 
> DB.  I was wondering if there is a way that I can store the 
> password in the DB so that it is encrypted or something.  
> Just so it is not in plain text.

You can use, 

SQL> Insert into users_table(user_name, pass_word) values ('your_name',
PASSWORD('your_pass'));

And crypted password will be saved in the DB

To verify password you can use something like...

SQL> select * from users_table where user_name = 'your_name' and
pass_word = PASSWORD('your_pass');

If the select query is not empty then user credentials are matching.

As others have suggested PHP crypt functions are useful when you want to
encrypt data within the DB like credit card details, Company Executives
Salary and stuff like that. For password encryption the best is MySQL
inbuilt encryption. MD5 is another I use with PHP, which is not really
necessary.

Kosala

www.linux.lk/~kosala/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux