<?php include 'header.php'; ?>
<div class="kontainer-besar halaman-atas jarakbawahatas-5 mb-5 wow fadeIn" data-wow-delay="0.1s">
	<div class="kontainer teks-tengah jarakbawahatas-5">
		<h1 class="tampilan-3 teks-hitam jarakbawah-4 animated slideInDown" style="color:white!important">Masuk</h1>
		<nav aria-label="bagian-atas animated slideInDown">
			<ol class="bagian-atas konten-tengah mb-0">
				<li class="bagian-atas-item"><a href="index.php">Home</a></li>
				<li class="bagian-atas-item active" aria-current="page">Masuk</li>
			</ol>
		</nav>
	</div>
</div>
<div class="kontainer-xxl jarakbawahatas-5">
	<div class="kontainer">
		<div class="teks-tengah mx-auto wow fadeInUp" data-wow-delay="0.1s" style="max-width: 500px;">
			<p class="judul background-putih teks-tengah warnateks-utama jarakkirikanan-3">Masuk</p>
			<h1 class="mb-5">Masuk</h1>
		</div>
		<div class="row g-5">
			<div class="kolom-besar-12 wow fadeInUp" data-wow-delay="0.1s">
				<form method="post">
					<div class="row g-3">
						<div class="kolom-sedang-12">
							<label class="mb-2">Username</label>
							<input type="text" name="username" class="gaya-formulir" required>
						</div>
						<div class="kolom-sedang-12">
							<label class="mb-2">Password</label>
							<input type="password" name="password" class="gaya-formulir" required>
						</div>
						<div class="col-12">
							<button class="tombol tombol-kedua lingkaran-pill jarakbawahatas-3 jarakkirikanan-5 w-100" type="submit" name="simpan">Masuk</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
<?php
if (isset($_POST["simpan"])) {
	$username = $_POST["username"];
	$password = $_POST["password"];
	$ambil = $koneksi->query("SELECT * FROM admin WHERE username='$username' AND password='$password' LIMIT 1");
	$akunyangcocok = $ambil->num_rows;

	if ($akunyangcocok == 1) {
		$akun = $ambil->fetch_assoc();
		$_SESSION['admin'] = $akun;
		echo "<script>alert('Anda berhasil masuk!');</script>";
		echo "<script>location ='admin/index.php';</script>";
	} else {
		echo "<script>alert('Username/Password salah!');</script>";
		echo "<script>location ='login.php';</script>";
	}
}
?>

<?php
include 'footer.php';
?>