你能解释为什么我的sql请求验证不起作用吗? 它始终显示“的问题......”即使新用户加入我的数据库..验证请求sql
<?php
include 'conn_mysql.php';
if (isset($_POST['Login_fieldR']) && isset($_POST['Password_fieldR'])){
$login_fieldR = $_POST['Login_fieldR'];
$password_fieldR = $_POST['Password_fieldR'];
$dateregister=NULL;
try{
$bdd = new PDO($conStr,$user,$pass);
} catch (PDOException $e){
die('could not connect to the database'.$e->getMessage());
}
$req = $bdd->prepare('INSERT INTO users(login, password, dateregister) VALUES(?, ?, NOW())');
$req->execute(array($login_fieldR,$password_fieldR));
$result = $req->fetch();
if (!$result)
{
echo '<p id="popup_text">Problem..</p>';
}
else
{
echo '<p id="popup_text">You are registered ! You can logged in now';
}
}
?>
**决不* *存储纯文本密码。请使用['password_hash()'](http://us3.php.net/manual/en/function.password-hash.php)和['password_verify()'](http://us3.php.net) /manual/en/function.password-verify.php)。如果您使用的是5.5之前的PHP版本,请不要**使用MD5或SHA1来散列密码。相反,您可以使用[此兼容包](https://github.com/ircmaxell/password_compat)。 –
@AlexHowansky好的,谢谢,我会用它! :) – Melinsuna
'fetch()'需要'SELECT',而不是'INSERT'。 –