<?php
session_start();

// Predefined username and password
$valid_username = 'admin';
$valid_password = 'Lake92040#'; // Change this to something secure!

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  $username = $_POST['username'];
  $password = $_POST['password'];

  if ($username === $valid_username && $password === $valid_password) {
    $_SESSION['authenticated'] = true;
    header('Location: view-rsvp.php');
    exit;
  } else {
    $error = "Invalid credentials";
  }
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <title>Login</title>
  <link rel="stylesheet" href="../css/admin.css" />
</head>
<body class="login-page">

  <form method="post">
    <h2>Login</h2>
    <?php if (!empty($error)) echo "<p class='error'>$error</p>"; ?>
    <input type="text" name="username" placeholder="Username" required><br />
    <input type="password" name="password" placeholder="Password" required><br />
    <button type="submit">Login</button>
  </form>

</body>
</html>