sha1密码到数据库

时间:2017-04-12 15:22:15

标签: php mysql pdo

    <?php
if(isset($_POST["submit"])){    
    $userid = htmlspecialchars($_POST["userid"]);
    $password = htmlspecialchars($_POST["wachtwoord"]);
    $passwordcrypt = sha1($password);

       $sql = "INSERT INTO user (userid, wachtwoord) VALUES ($userid, $passwordcrypt);";

    $conn->exec($sql);
    echo "New record created successfully";
}
?>

当我使用

$passwordcrypt = sha1($password);

我收到错误:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column '356a192b7913b04c54574d18c28d46e6395428ab' in 'field list'' in C:\xampp\htdocs\school\php\registration.php:30 Stack trace: #0 C:\xampp\htdocs\school\php\registration.php(30): PDO->exec('INSERT INTO use...') #1 {main} thrown in C:\xampp\htdocs\school\php\registration.php on line 30

如果我不使用SHA1然后它可以工作,为什么它不能这样工作?

0 个答案:

没有答案