我在这里检查了类似的问题,但它无法解决我的问题。我正在创建一个php用户注册表单,当我尝试注册时,我收到此错误:严格的标准:只有变量应该在第14行的F:\ wamp64 \ www \ login \ register.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;
?>
感谢任何帮助,谢谢。
答案 0 :(得分:0)
尝试
Healthy threshold