prepare("SELECT * FROM users WHERE username = :username LIMIT 1"); $stmt->execute(['username' => $username]); $user = $stmt->fetch(); if ($user && password_verify($password, $user['password_hash'])) { $_SESSION['admin_logged_in'] = true; $_SESSION['admin_username'] = $user['username']; $_SESSION['admin_role'] = $user['role']; header("Location: " . BASE_URL . "admin/index.php"); exit(); } else { $error = "Invalid credentials. Please try again."; } } catch (PDOException $e) { // Simulated offline developer bypass for easy testing if ($username === 'admin' && $password === 'admin123') { $_SESSION['admin_logged_in'] = true; $_SESSION['admin_username'] = 'admin'; $_SESSION['admin_role'] = 'admin'; header("Location: " . BASE_URL . "admin/index.php"); exit(); } else { $error = "Database Connection Offline. Use standard 'admin' and 'admin123' to bypass connection errors for local mockups."; } } } } ?>
Control System Portal