Here is what it's saying:
Notice: Only variables should be passed by reference in C:\xampp\htdocs\loginegister.php on line 20
In line 20, I have
$stmt->bindParam(':password', password_hash($_POST['password'], PASSWORD_BCRYPT));
Can someone help me out?
Store value of hash in a variable and then pass it.
$password = password_hash($_POST['password'], PASSWORD_BCRYPT);
$stmt->bindParam(':password', $password);
For more reference: http://php.net/manual/en/pdostatement.bindparam.php
Avoid function call in Statement#bindParam
, its return value cannot be passed as reference.
Try to separate the function call: $pwd = password_hash($_POST['password'], PASSWORD_BCRYPT); $stmt->bindParam(':password', $pwd);
More info on passing values by reference: http://php.net/manual/en/language.references.pass.php
The second parameter of bindParam is a variable reference. Since a function return cannot be referenced, it fails to strictly meet the needs of the bindParam parameter.
$password = password_hash($_POST['password'], PASSWORD_BCRYPT);
$stmt->bindParam(':password', $password);
You must first Store the value of password_hash($_POST['password'] in a variable ($pwd) and then pass it
$pwd = password_hash($_POST['password'], PASSWORD_BCRYPT);
$stmt->bindParam(':password', $pwd);
Yes, it works
It is part of PHP Regiter, Login, Logout script available at following link: https://github.com/thedevdojo/php-login-script