I have a script code to login.
Unfortunately this using sha1
is no longer recommended. I tried to change it to password_hash()
but it failed.
Original
public static function create($username, $password)
{
$q = self::$db->prepare('INSERT INTO user(username, password, email) VALUES (:username, :password, :email)');
return $q->execute(array(
':username' => $username,
':password' => sha1($password),
':email' => $email,
));
}
Edit
public static function create($username, $password)
{
$q = self::$db->prepare('INSERT INTO user(username, password, email) VALUES (:username, :password, :email)');
$new_password = password_hash($password, PASSWORD_DEFAULT);
return $q->execute(array(
':username' => $username,
':password' => $new_password,
':email' => $email,
));
}
What's wrong with it?