0) { http_response_code(429); $error = 'Too many failed attempts. Try again in ' . (int) ceil($lockSeconds / 60) . ' minute(s).'; } elseif (authenticate_user($username, $password)) { clear_login_failures($ip, $throttleKey); header('Location: index.php'); exit; } else { record_login_failure($ip, $throttleKey); $error = 'Invalid username or password.'; } } ?>