9951 explained code solutions for 126 technologies


php-pdoHash passwords for usage with PHP PDO


$st = $pdo->prepare('INSERT INTO users SET login = :login, pwd = :pwd');
$st->execute([':login' => $_POST['login'], ':pwd' => password_hash($_POST['pwd'])]);ctrl + c
$pdo->prepare

prepare given query to execute

INSERT INTO users

sample INSERT query

$st->execute(

run query on the server

:pwd

password placeholder

password_hash

generates secure password hash used with password_verify() to check passwords on login

$_POST['pwd']

original password (posted by user)