Hello.
I’m trying to setup users with a pre-determined password. The problem is that say I give them password 12345, and that’s why I’ve input as their password in mySql. Well…it gets a password incorrect error. I’m sure this has something to do with encrypting the password…but how do I change the 12345 into an encryption?
When you generate the password you should do the same hashing routine as when a user logs in.
If you are on PHP >= 5.5 then you should use the built in password_hash and password_verify functions
http://php.net/manual/en/function.password-hash.php
If you are on an older version you could use this compatability pack while waiting for your host to upgrade
these use Bcrypt, which is one of the two most thought of hashing routines for passwords these days. Remember to set the cost factor as high as possible for your system (should use 0,3-0,5s / hash)
Looking at my php, this is what I see with regards to the password:
[php] $_POST[‘pass’] = stripslashes($_POST[‘pass’]);
$info['password'] = stripslashes($info['password']);
$_POST['pass'] = md5($_POST['pass']);
[/php]
However, I’m trying to do an import into myphp from a CSV file, so how do I make the “12345” that’s imported from the CSV file do this?
Just do it to the password before inserting it into the database. Just remember that in some countries it’s illegal to not handle user data properly.
Thank you. But how do it do it to the password before inserting it into the DB?
Add the code you use to parse the csv/insert it into the db.