<?php include("config.php"); ?><!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>SMP IT ADZIKRI</title>
    <meta content="width=device-width, initial-scale=1.0" name="viewport">
    <meta content="" name="keywords">
    <meta content="" name="description">

    <!-- Favicon -->
    <link href="img/smpadzikri.png" rel="icon">

    <!-- Google Web Fonts -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Heebo:wght@400;500;600&family=Inter:wght@600&family=Lobster+Two:wght@700&display=swap" rel="stylesheet">
    
    <!-- Icon Font Stylesheet -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.4.1/font/bootstrap-icons.css" rel="stylesheet">

    <!-- Libraries Stylesheet -->
    <link href="lib/animate/animate.min.css" rel="stylesheet">
    <link href="lib/owlcarousel/assets/owl.carousel.min.css" rel="stylesheet">

    <!-- Customized Bootstrap Stylesheet -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- Template Stylesheet -->
    <link href="css/style.css" rel="stylesheet">
</head>

<body>
    <div class="container-xxl bg-white p-0">
    <?php include("navbar.php"); ?>



        <!-- Appointment Start -->
        <div class="container-xxl py-5">
            <div class="container">
                <div class="bg-light rounded">
                    <div class="row g-0">
                        <div class="col-lg-6 wow fadeIn" data-wow-delay="0.1s">
                            <div class="h-100 d-flex flex-column justify-content-center p-5">
                                <h1 class="mb-4">Form Pendaftaran</h1>
                                <form action="proses-pendaftaran.php" method="POST">
                                    <div class="row g-3">
                                    <div class="col-sm-6">
                                        <div class="form-floating">
                                            <input type="text" name="nisn" placeholder="NISN" />
                                            <label for="nisn"></label>
                                            </div>
                                        </div>
                                        <div class="form-floating">
                                            <input type="text" name="nik" placeholder="NIK" />
                                            <label for="nik"></label>
                                            </div>
                                        </div>
                                        <div class="col-sm-6">
                                            <div class="form-floating">
                                            <input type="text" name="nama" placeholder="Nama Lengkap" />
                                            <label for="nama"></label>
                                            </div>
                                        </div>
                                        <div class="col-sm-6">
                                            <div class="form-floating">
                                            <input type="text" name="t_lahir" placeholder="Tempat Lahit" />
                                            <label for="t_lahir"></label>
                                            </div>
                                        </div>
                                        <div class="col-sm-6">
                                            <div class="form-floating">
                                            <input type="text" name="tg_lahir" placeholder="Tanggal Lahir" />
                                            <label for="tg_lahir"></label>
                                            </div>
                                        </div>
                                        <div class="col-sm-6">
                                                <label for="jenis_kelamin">Jenis Kelamin</label>
                                                <select name="jk" id="jk">
                                                <option value="pilih">Pilih</option>
                                                <option value="laki-laki">Laki-laki</option>
                                                <option value="perempuan">Perempuan</option>
                                                </select>
                                        </div>
                                        <div class="col-sm-12">
                                            <div class="form-floating">
                                            <textarea name="alamat" placeholder="Alamat"></textarea>
                                            <label for="alamat"></label>
                                            </div>
                                        </div>
                                        <div class="col-sm-12">
                                            <div class="form-floating">
                                            <textarea name="ayah" placeholder="Nama Ayah"></textarea>
                                            <label for="ayah"></label>
                                            </div>
                                        </div>
                                        <div class="col-sm-12">
                                            <div class="form-floating">
                                            <textarea name="ibu" placeholder="Nama Ibu"></textarea>
                                            <label for="ibu"></label>
                                            </div>
                                        </div>
                                        <div class="col-sm-6">
                                            <div class="form-floating">
                                            <input type="text" name="sekolah" placeholder="Sekolah Asal" />
                                            <label for="sekolah"></label> 
                                            </div>
                                        </div>
                                        <div class="col-sm-6">
                                            <div class="form-floating">
                                            <input type="text" name="no_hp" placeholder="No HP" />
                                            <label for="no_hp"></label> 
                                            </div>
                                        </div>
                                        <div class="col-12">
                                            <button class="btn btn-primary w-100 py-3" type="submit" value="Daftar" name="daftar">Daftar</button>
                                        </div>
                                    </div>
                                </form>
                                <?php
                    				include('koneksi.php');
                    				
                    				//melakukan pengecekan jika button submit diklik maka akan menjalankan perintah simpan dibawah ini
                    				if (isset($_POST['submit'])) {
                    					//menampung data dari inputan
                    					$nisn = $_POST['nisn'];
                                        $nik = $_POST['nik'];
                                        $nama = $_POST['nama'];
                                        $t_lahir = $_POST['t_lahir'];
                                        $tg_lahir = $_POST['tg_lahir'];
                                        $jk = $_POST['jk'];
                    					$alamat = $_POST['alamat'];
                    					$ayah = $_POST['ayah'];
                                        $ibu = $_POST['ibu'];
                                        $sekolah = $_POST['sekolah'];
                                        $no_hp = $_POST['no_hp'];
                    
                    					//query untuk menambahkan barang ke database, pastikan urutan nya sama dengan di database
                    					$datas = mysqli_query($koneksi, "insert into pendaftar (nisn,nik,nama,t_lahir,tg_lahir,jk,alamat,ayah,ibu,sekolah,no_hp)values
                                        ('$nisn','$nik','$nama', '$t_lahir','$tg_lahir','$jk','$alamat','$ayah','$ibu','$sekolah','$no_hp')") or die
                    					(mysqli_error($koneksi));
                    					//id barang tidak dimasukkan, karena sudah menggunakan AUTO_INCREMENT, id akan otomatis
                    
                    					//ini untuk menampilkan alert berhasil dan redirect ke halaman index
                    					echo "<script>alert('data berhasil disimpan.');window.location='index.php';</script>";
                    				}
                    				?>
                            </div>
                        </div>
                        <div class="col-lg-6 wow fadeIn" data-wow-delay="0.5s" style="min-height: 400px;">
                            <div class="position-relative h-100">
                                <img class="position-absolute w-100 h-100 rounded" src="img/5.jpeg" style="object-fit: cover;">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- Appointment End -->


        <!-- Footer Start -->
        <div class="container-fluid bg-dark text-white-50 footer pt-5 mt-5 wow fadeIn" data-wow-delay="0.1s">
            <div class="container py-5">
                <div class="row g-5">
                    <div class="col-lg-3 col-md-6">
                        <h3 class="text-white mb-4">Tentang Kami</h3>
                        <p class="mb-2"><i class="fa fa-map-marker-alt me-3"></i>Kp. Ciceuri Rt 03/02, Sukamandi, Kec. Sagalaherang, Kab. Subang Prov. Jawa Barat</p>
                        <p class="mb-2"><i class="fa fa-phone-alt me-3"></i>+62 856-2428-2881</p>
                        <p class="mb-2"><i class="fa fa-envelope me-3"></i>smp.it.adzikri@gmail.com</p>
                        <div class="d-flex pt-2">
                            <a class="btn btn-outline-light btn-social" href=""><i class="fab fa-twitter"></i></a>
                            <a class="btn btn-outline-light btn-social" href=""><i class="fab fa-facebook-f"></i></a>
                            <a class="btn btn-outline-light btn-social" href=""><i class="fab fa-youtube"></i></a>
                            <a class="btn btn-outline-light btn-social" href=""><i class="fab fa-linkedin-in"></i></a>
                        </div>
                    </div>
                </div>
            </div>
            <div class="container">
                <div class="copyright">
                    <div class="row">
                        <div class="col-md-6 text-center text-md-start mb-3 mb-md-0">
                            &copy; <a class="border-bottom" href="#">SMP IT ADZIKRI</a>, All Right Reserved. 
					
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- Footer End -->


        <!-- Back to Top -->
        <a href="#" class="btn btn-lg btn-primary btn-lg-square back-to-top"><i class="bi bi-arrow-up"></i></a>
    </div>

    <!-- JavaScript Libraries -->
    <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/js/bootstrap.bundle.min.js"></script>
    <script src="lib/wow/wow.min.js"></script>
    <script src="lib/easing/easing.min.js"></script>
    <script src="lib/waypoints/waypoints.min.js"></script>
    <script src="lib/owlcarousel/owl.carousel.min.js"></script>

    <!-- Template Javascript -->
    <script src="js/main.js"></script>
</body>

</html>