我收到一个 PHP 错误并在 hurl.it 上返回空正文。我试图散列我数据库中现有用户的密码。
使用 user_id 作为 POST 并在新创建的列中将其更新到我的数据库
// Create connection
$con = mysqli_connect($dbPath,$dbUserName,$dbPassword,$dbSchema);
// Check connection
if (mysqli_connect_errno()) {
$error = "DB connection error";
}
$user_id = $_POST['user_id'];
//exisitng password
$sql = mysqli_query($con, "SELECT password FROM user_table
WHERE user_id = '$user_id'");
if(!$sql) $error = "SELECT user_table error";
$i=0;
while($result = mysqli_fetch_assoc($sql)){
$hash[$i] = $result;
if($hash[$i]) {
$check_hash = password_hash($hash[$i], PASSWORD_DEFAULT);
//store into DB
$result2 = mysqli_query($con, "INSERT INTO user_table (password_secure) VALUES ('$check_hash')");
}
$i++;
}
if(!$result2) $error = "INSERT user_table error";
// Set returns
if (!$error) $status = "successful";