Edit: My issue has been resolved. I did not know or think of bindValue(), that is why I do not think this is a duplicate question. Thanks for the help!
I am learning how to register users with PHP and it seems like password_hash is giving me the "Only Variables should be passed by reference" error message. I've seen many people with the same error, but it does not seem to apply to my case (in my opinion).
connecting to database
$server = 'localhost';
$username ='root';
$password ='root';
$database = 'register_test';
try{
$conn = new PDO("mysql:host=$server;dbname=$database;" , $username, $password);
} catch(PDOException $e){
die ("Connection failed" . $e->getMessage());
}
Registering user
require 'database.php';
if(!empty($_POST['email']) && !empty($_POST['password'])):
$pass = $_POST['password'];
$email = $_POST['email'];
$sql = "Insert into user (email, password) values (:email, :password)";
$stmt = $conn->prepare($sql);
$stmt ->bindParam(':email', $email);
$stmt ->bindParam(':password', password_hash($pass, PASSWORD_BCRYPT)); //error showns here
if($stmt -> execute() ):
die('Success');
else:
die('Fail');
endif;
endif;
If you guys need more information please let me know.