0
我在这里查了类似的问题,但它不能解决我的问题。我正在创建一个php用户注册表单,当我尝试注册时,我得到这个错误:严格标准:只有变量应该通过引用传递给第14行的F:\ wamp64 \ www \ login \ register.php只有变量应该通过引用传递php
我在PHP版本5.6和7.0上试过,但是错误是一样的。
14号线是这样的:
$stmt->bindParam(':password', password_hash($_POST['password'], PASSWORD_BCRYPT));
这里是我的全部代码:
<?php
$server = 'localhost';
$username = 'root';
$password = 'root';
$database = 'auth';
try{
$conn = new PDO("mysql:host=$server;dbname=$database;", $username, $password);
} catch(PDOException $e) {
die("Connection failed: " . $e->getMessage());
}
$message = '';
if(!empty($_POST['email']) && !empty($_POST['password'])):
$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 account';
endif;
endif;
?>
任何帮助表示赞赏,感谢。
感谢您的答复,但它给了我2个错误:注意:未定义指数:密码F:\ wamp64 \第5行,并警告WWW \登录\ register.php:password_hash( )期望至少2个参数,1给出在第5行F:\ wamp64 \ www \ login \ register.php – PapT
我编辑了我的代码,试试这个 –
谢谢。对于$ phash – PapT