正确验证请求

时间:2017-06-14 15:19:34

标签: php sql

我想我错过了验证PHP请求的一些内容。我实际上在做$result = $req->fetch();,但result因某种原因总是返回false。

$bdd = new PDO($conStr,$user,$pass);
$req = $bdd->prepare('INSERT INTO users(login, password, dateregister) VALUES(?, ?, NOW())');
$req->execute(array($loginR,$passwordR));

$result = $req->fetch();

1 个答案:

答案 0 :(得分:1)

检查执行功能的返回值是否成功/失败消息

$res = $req->execute(array($login_fieldR,$password_fieldR));
   if (!$res )
    {
        echo '<p id="popup_text">Problem..</p>';
    }
    else
    {
        echo '<p id="popup_text">You are registered ! You can logged in now';
    }