I can enter index.php when i register an account and let it redirect me but once i log out and log in again it say Access Denied any idea?? the register.php works perfectly but my guess is login.php logic is broken?
register.php
{
$hashed_password = password_hash($password, PASSWORD_BCRYPT);
if(password_verify($password, $hashed_password)) {
$query = "SELECT * FROM users WHERE username='$username' AND password='$password'";
$results = mysqli_query($db, $query);
}
if (mysqli_num_rows($results) == 1) {
$_SESSION['username'] = $username;
header('location: index.php'); // this redirect me perfectly
die();
}else {
array_push($errors, "ACCESS DENIED!");
}
}
login.php
{
$hashed_password = password_hash($password, PASSWORD_BCRYPT);
if(password_verify($password, $hashed_password)) {
$query = "SELECT * FROM users WHERE username='$username' AND password='$password'";
$results = mysqli_query($db, $query);
}
if (mysqli_num_rows($results) == 1) {
$_SESSION['username'] = $username;
header('location: index.php');
die();
}else {
array_push($errors, "ACCESS DENIED!"); // i'm being drop here
}
}