php bcrypt 505错误

时间:2014-08-23 23:40:48

标签: php hash string-hashing

我正在尝试为用户的电子邮件和密码使用简单的哈希。 但是,当我运行以下在ajax请求上调用的php脚本时,我发送了505错误。

<?php

$user = json_decode(file_get_contents('php://input'));
$email = $user->email;
$pass = $user->pass;
$cpass = $user->cpass;
$ssid = $user->ssid;
$type = $user->type;
$date = $user->regtime;

$con = mysqli_connect("localhost", "", "", "");
// Check connection
if (mysqli_connect_errno()){
    echo "Failed to connect to MySQL: " . mysqli_connect_error(); 
}

$validateEmail = "SELECT `Email` FROM `newUsers` WHERE `Email` = '$email' ";


$newVar = password_hash($pass, PASSWORD_DEFAULT);

if ($result = mysqli_query($con,$validateEmail)) {
     if ($result->num_rows == 0){   
        $sql = "INSERT INTO `newUsers`(`email`, `type`, `date`, `ssid`, `hashpass`) VALUES ('$email', '$type', '$date', '$ssid', '$newVar')";
        mysqli_query($con,$sql);
    }
}
mysqli_close($con);
?> 

如果我删除散列尝试并保留接收密码,则密码会被插入,所以我相信它是导致505的散列函数。任何人都可以看到我的散列尝试出了什么问题?

0 个答案:

没有答案