以下是我的PHP代码.
<?php
session_start();
if(isset($_SESSION['user_id'])) {
header("Location: /");
}
require 'database.php';
$message = '';
if(!empty($_POST['email']) && !empty($_POST['password'])):
//Enter the new user in the database.
$sql ="INSERT INTO users (email, password) VALUES(:email, :password)";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':email', $_POST['email']);
$stmt->bindParam(':password',password_hash($_POST['password'], PASSWORD_BCRYPT));
if ($stmt->execute()):
$message = 'successfully created new user';
else:
$message = 'Sorry there must have been an issue creating your an account.';
endif;
endif;
Run Code Online (Sandbox Code Playgroud)
它显示错误说:
注意:在第17行的C:\ xampp\htdocs\auth\register.php中只能通过引用传递变量
在第17行,以下代码位于:
$stmt->bindParam(':password',password_hash($_POST['password'], PASSWORD_BCRYPT));
Run Code Online (Sandbox Code Playgroud)
知道问题是什么,只有变量应该通过引用传递?