<?php
    include "koneksi.php";
    session_start();
    if (isset($_SESSION['nama_pengguna_akun'])) {
        header("location: index.php");
    }
?>

<?php
    $qry_hadiah = mysqli_query($koneksi, "SELECT * FROM atur_situs WHERE id='1'") 
                   or die("Query Error: " . mysqli_error($koneksi));
               
               $dt_bank = mysqli_fetch_array($qry_hadiah);
               
               // Jika data tidak ditemukan, gunakan nilai default kosong
               $nama_situs = $dt_bank['nama_situs'] ?? '';
               $title_situs = $dt_bank['title_situs'] ?? '';
               $meta_deskripsi = $dt_bank['meta_deskripsi'] ?? '';
               $logo = $dt_bank['logo'] ?? '';
               $favicon = $dt_bank['favicon'] ?? '';
               $background_situs = $dt_bank['background_situs'] ?? ''; // Sesuai dengan tabel
               $slider_banner = $dt_bank['slider_banner'] ?? '';
               $link_daftar = $dt_bank['link_daftar'] ?? '';
               $link_login = $dt_bank['link_login'] ?? '';
               $link_klaim = $dt_bank['link_klaim'] ?? '';
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0" name="viewport">
  <title>HALAMAN LOGIN</title>
  <meta content="" name="description">
  <meta content="" name="keywords">
  <!-- Favicons -->
  <link href="../img/<?php echo $favicon; ?>" rel="icon">
  <link href="../img/<?php echo $favicon; ?>" rel="apple-touch-icon">
  <!-- Google Fonts -->
  <link href="https://fonts.gstatic.com" rel="preconnect">
  <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Nunito:300,300i,400,400i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i" rel="stylesheet">
  <!-- Vendor CSS Files -->
  <link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <link href="assets/vendor/bootstrap-icons/bootstrap-icons.css" rel="stylesheet">
  <link href="assets/vendor/boxicons/css/boxicons.min.css" rel="stylesheet">
  <link href="assets/vendor/quill/quill.snow.css" rel="stylesheet">
  <link href="assets/vendor/quill/quill.bubble.css" rel="stylesheet">
  <link href="assets/vendor/remixicon/remixicon.css" rel="stylesheet">
  <link href="assets/vendor/simple-datatables/style.css" rel="stylesheet">
  <!-- Template Main CSS File -->
  <link href="assets/css/style.css" rel="stylesheet">
  <link rel="stylesheet" href="../css/main.css">
</head>
<body style="background-image: url(../img/<?php echo $background_situs; ?>);">
  <main class="bg-dark bg-opacity-50">
    <div class="container">
      <section class="section register min-vh-100 d-flex flex-column align-items-center justify-content-center py-4">
        <div class="container">
          <div class="row justify-content-center">
            <div class="col-lg-4 col-md-6 d-flex flex-column align-items-center justify-content-center">
              <div class="d-flex justify-content-center align-items-center w-auto py-4">
                <img src="../img/<?php echo $logo; ?>" alt="" class="img-fluid">
              </div>
              <div class="card bg-light bg-opacity-25 mb-3">
                <div class="card-body">
                  <?php
                      if (isset($_GET['notif'])) {
                          if ($_GET['notif'] == "data_salah") {
                              echo '
                                  <div class="alert alert-danger mt-3" role="alert">
                                      Data yang anda masukan salah, coba lagi!.
                                  </div>
                              ';
                          }
                      }
                  ?>
                  <form action="prs_masuk.php" method="post" class="row g-3 needs-validation" novalidate>
                    <div class="col-12">
                      <div class="form-floating mt-3">
                        <input type="text" class="form-control bg-light bg-opacity-50" id="nama_pengguna_akun" name="nama_pengguna_akun" placeholder="Nama Pengguna" required>
                        <label for="nama_pengguna_akun">Nama Pengguna</label>
                      </div>
                    </div>
                    <div class="col-12">
                      <div class="form-floating">
                        <input type="password" class="form-control bg-light bg-opacity-50" id="kata_sandi_akun" name="kata_sandi_akun" placeholder="Kata Sandi" required>
                        <label for="kata_sandi_akun">Kata Sandi</label>
                      </div>
                    </div>
                    <div class="col-12">
                      <button class="btn btn-primary w-100" type="submit">Masuk</button>
                    </div>
                  </form>
                </div>
              </div>
            </div>
          </div>
        </div>
      </section>
    </div>
  </main>
  <a href="#" class="back-to-top d-flex align-items-center justify-content-center"><i class="bi bi-arrow-up-short"></i></a>
  <!-- Vendor JS Files -->
  <script src="assets/vendor/apexcharts/apexcharts.min.js"></script>
  <script src="assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
  <script src="assets/vendor/chart.js/chart.min.js"></script>
  <script src="assets/vendor/echarts/echarts.min.js"></script>
  <script src="assets/vendor/quill/quill.min.js"></script>
  <script src="assets/vendor/simple-datatables/simple-datatables.js"></script>
  <script src="assets/vendor/tinymce/tinymce.min.js"></script>
  <script src="assets/vendor/php-email-form/validate.js"></script>
  <!-- Template Main JS File -->
  <script src="assets/js/main.js"></script>
</body>
</html>