-
MySQL Encryption
Hey.
Im sort of new to MySQL. Im combining it with PHP to create a user system. I am using phpmyadmin to manage my databases.
I was wondering, how do i encrypt my password field? I know how to encrypt passwords AFTER they have been added, but how do i get it too encrypt my password field automaticly when its added?
Thanks, MrStretch
-
You just use md5() before saving it onto the database
-
Ok.
This is the query to insert the information from the form into the database. Can you add the md5() function into it? Im not sure where to put it.
mysql_query("INSERT INTO members SET name='{$HTTP_POST_VARS['username']}', creds='{$HTTP_POST_VARS['creds']}', password='{$HTTP_POST_VARS['password']}'")
Thanks :-)
-
www.php.net/md5
Read and learn.
-
mysql_query("INSERT INTO members SET name='{$HTTP_POST_VARS['username']}', creds='{$HTTP_POST_VARS['creds']}', password='{$HTTP_POST_VARS['password']}'")
Change to:
$name = $_POST['username'];
$creds = $_POST['creds'];
$pass = md5($_POST['password']);
mysql_query("INSERT INTO members (`name` , `creds` , `password`) VALUES ('$name' , '$creds' , '$pass')");
Edit:
Remember to md5 it where you login by putting md5($_POST['whatever'])
-
Thank you very much :-)
Ive figured it out now.
-