prepare("SELECT * FROM users WHERE email = ?"); $stmt->execute([$_POST['email']]); $user = $stmt->fetch(); if ($user && password_verify($_POST['password'], $user['password'])) { // Password is correct, start session $_SESSION['user_id'] = $user['id']; $_SESSION['user_email'] = $user['email']; $_SESSION['user_role'] = $user['role']; // Redirect to the appropriate dashboard if ($user['role'] === 'staff') { header("Location: staff_dashboard.php"); } else { header("Location: resident_dashboard.php"); } exit; } else { $error_message = 'Invalid email or password.'; } } catch (PDOException $e) { $error_message = 'Database error. Please try again later.'; // In a real app, you would log this error } } } ?>
Welcome to the Continuum of Healing™