I have an old website with users and password (not hashed) and want to import them into mysql, then run a script to create a new user_password_hash and update the database:
what I tried is something like this:
require 'application/config/config.php';
#Define Connection String Using PDO.
$dbh = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8',DB_USER,DB_PASS);
$sth = $dbh->prepare("SELECT user_id, password, user_password_hash FROM users");
$sth->execute();
$result = $sth->fetchAll();
foreach($result as $key => $value)
{
$query = "UPDATE users
SET user_password_hash = password_hash('result.password', PASSWORD_DEFAULT)
WHERE user_id = 'result.user_id'";
}
echo 'Done';
but not working
tried it a few different ways but unsuccessfully frustrating,
new to php, used cfm in the past, trying to get my php feet wet !!!
any suggestions are appreciated !!!