Кто подскажет почему не хешируется пароль? Как правильно написать? После регистрации error=none, значит ошибок нет но почему не работает хеширование не знаю.
function emptyInputSignup($username, $email, $pwd, $pwdRepeat) {
$result;
if (empty($username) || empty($email) || empty($pwd) || empty($pwdRepeat)) {
$result = true;
}
else {
$result = false;
}
return $result;
}
function invalidUid($username) {
$result;
if (!preg_match("/^[a-zA-Z0-9]*$/", $username)) {
$result = true;
}
else {
$result = false;
}
return $result;
}
function invalidEmail($email) {
$result;
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$result = true;
}
else {
$result = false;
}
return $result;
}
function pwdMatch($pwd, $pwdRepeat) {
$result;
if ($pwd !== $pwdRepeat) {
$result = true;
}
else {
$result = false;
}
return $result;
}
function uidExists($conn, $username, $email) {
$sql = "SELECT * FROM users WHERE usersUid = ? OR usersEmail = ?;";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
header("location: ../Login/index.php?error=stmtfailed");
exit();
}
mysqli_stmt_bind_param($stmt, "ss", $username, $email);
mysqli_stmt_execute($stmt);
$resultData = mysqli_stmt_get_result($stmt);
if ($row = mysqli_fetch_assoc($resultData)) {
return $row;
}
else {
$result = false;
return $result;
}
mysqli_stmt_close($stmt);
}
function createUser($conn, $email, $username, $pwd) {
$sql = "INSERT INTO users (usersEmail, usersUid, usersPwd) VALUES (?, ?, ?);";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
header("location: ../Login/index.php?error=stmtfailed");
exit();
}
$hashedPwd = password_hash($pwd, PASSWORD_DEFAULT);
mysqli_stmt_bind_param($stmt, "sss", $email, $username, $pwd);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
header("location: ../Login/index.php?error=none");
exit();
}