$options = [ 'cost' => 12, ]; $password = password_hash($_POST['password'], PASSWORD_BCRYPT, $options);
// on dialog response, register
bcrypt_hash(inputtext, BCRYPT_COST, "OnAccountPasswordHash", "d", playerid);
public OnAccountPasswordChange(playerid) {
new msg[128];
new hash[BCRYPT_HASH_LENGTH];
bcrypt_get_hash(hash);
mysql_format(sqlHandle, msg, sizeof(msg), "UPDATE `users` SET `password` = '%e' WHERE `id` = '%d'", hash, GetPVarInt(playerid, "AccountID"));
mysql_function_query(sqlHandle, msg, false, "", "");
SendClientMessage(playerid, COLOR_LIGHTRED, "* Your password has been changed.");
format(msg, sizeof(msg), "%s changed %s password.", PlayerInfo[playerid][pName], HisHer(playerid));
return 1;
}
if (password_verify($pw, $hash)) {
echo 'Password is valid!';
} else {
echo 'Invalid password.';
}
<?php session_start(); require_once('config.php'); $options = [ 'cost' == 12, ]; $username = $_POST['username']; $password = password_verify($_POST['password'], PASSWORD_BCRYPT, $options); echo $password; $sql = "SELECT * FROM users WHERE username = ? AND password = ? LIMIT 1"; $stmtselect = $db->prepare($sql); $result = $stmtselect->execute([$username, $password]); if($result){ $user = $stmtselect->fetch(PDO::FETCH_ASSOC); if($stmtselect->rowCount() > 0) { $_SESSION['userlogin'] = $user; echo '1'; } else { echo 'There no user for that combo'; } } else { echo 'There were errors while connecting to database.'; }
Can you tell me how exactly I do that, when the file looks like this:
Code:
<?php session_start(); require_once('config.php'); $options = [ 'cost' == 12, ]; $username = $_POST['username']; $password = password_verify($_POST['password'], PASSWORD_BCRYPT, $options); echo $password; $sql = "SELECT * FROM users WHERE username = ? AND password = ? LIMIT 1"; $stmtselect = $db->prepare($sql); $result = $stmtselect->execute([$username, $password]); if($result){ $user = $stmtselect->fetch(PDO::FETCH_ASSOC); if($stmtselect->rowCount() > 0) { $_SESSION['userlogin'] = $user; echo '1'; } else { echo 'There no user for that combo'; } } else { echo 'There were errors while connecting to database.'; } |
// See the password_hash() example to see where this came from. $hash = '$2y$07$BCryptRequires22Chrcte/VlQH0piJtjXl.0t1XkA8pw9dMXTpOq'; if (password_verify('rasmuslerdorf', $hash)) { echo 'Password is valid!'; } else { echo 'Invalid password.'; }