Depending on how the data is being pulled i.e.
- Querying a database to check if the salt/md5/password_hash matches the data..
Please note the code I am showing is an example of something I have quickly wrote and will not work in your world application.. it is written for the MySQL Driver: PDO..
I don't know how much effort to put into these descriptions as this is my first ever freelance bid. Hope we can do some business!
public static function checkPassword($userID, $Password, $Type) {
global $db;
switch($Type) {
case "md5":
$select = $db->prepare('SELECT id FROM users WHERE id = :id AND password = :password');
$select->execute([
':id' => $userID,
':password' => $Password
]);
return ($select->rowCount() == 1) ? true : false;
break;
case "password_hash":
$select = $db->prepare('SELECT password FROM users WHERE id = :id');
$select->execute([
':id' => $userID
]);
$row = $select->fetch(PDO::FETCH_OBJ);
return password_verify($Password, $row->password);
break;
}
}