<?php
session_start();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
  $_SESSION['nama_cs'] = $_POST['nama_cs'];
  header("Location: menu_cs.php");
  exit;
}
?>

<!DOCTYPE html>
<html lang="id">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Login CS</title>
  <style>
    body {
      font-family: 'Segoe UI', sans-serif;
      display: flex;
      align-items: center;
      justify-content: center;
      height: 100vh;
      margin: 0;
      background: #f0f0f0;
    }
    .container {
      background: white;
      padding: 30px;
      border-radius: 10px;
      box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
      text-align: center;
      max-width: 400px;
      width: 100%;
    }
    h2 {
      margin-bottom: 20px;
    }
    select, button {
      width: 100%;
      padding: 12px;
      margin-top: 10px;
      font-size: 16px;
      border: 1px solid #ccc;
      border-radius: 6px;
      box-sizing: border-box;
    }
    button {
      background-color: #4CAF50;
      color: white;
      border: none;
      cursor: pointer;
      transition: background 0.3s;
    }
    button:hover {
      background-color: #45a049;
    }
  </style>
</head>
<body>
  <div class="container">
    <h2>🔐 Login CS</h2>
    <form method="POST">
      <label for="nama_cs">Pilih Nama CS:</label>
      <select name="nama_cs" id="nama_cs" required>
        <?php
        <?php
$host = "localhost";
$user = "odmr9632_userdb";
$pass = "@Sukabumi2018";
$db   = "odmr9632_order_db";

$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_error) {
  die("Koneksi gagal: " . $conn->connect_error);
}
?>
        $result = $conn->query("SELECT nama_cs FROM cs");
        while ($row = $result->fetch_assoc()) {
          echo "<option value='{$row['nama_cs']}'>{$row['nama_cs']}</option>";
        }
        ?>
      </select>
      <button type="submit">Masuk</button>
    </form>
  </div>
</body>
</html>