- password_verify: documentation ( source)
- trim: documentation ( source)
<?php
if ($_SESSION['logged'] == true) {
echo 'Здравейте ' . $username . '<br><br><a href="logout.php">Изход</a>';
} else {
if ($_POST) {
$username = trim($_POST['username']);
$password = $_POST[password];
$get = "SELECT * FROM `users` WHERE username=" . $username . "";
if ($result = mysqli_query($con, $get)) {
while ($row = mysqli_fetch_assoc($result)) {
$hash = $row['password'];
if (password_verify($password, $hash)) {
echo 'Valid';
} else {
echo 'Invalid';
}
}
}
if ($chek > 0) {
$_SESSION['logged'] = $username;
echo "Вие влязохте успешно.";
echo '<meta http-equiv="refresh" content="1;url=index.php"> ';
} else {
echo "Грешно потребителско име или парола.";
}
}
}
?>