<?php 
ob_start(); // Start output buffering
include 'header_admin.php';
include 'koneksi.php';

// Check if the form is submitted
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $id_siswa = $_POST['id_siswa'];
    $nisn = $_POST['nisn'];
    $nama_siswa = $_POST['nama_siswa'];
    $id_kelas = $_POST['id_kelas'];
    $id_pengguna = $_POST['id_pengguna'];
    $tanggal_lahir = $_POST['tanggal_lahir'];
    $alamat = $_POST['alamat'];
    $no_telepon = $_POST['no_telepon'];
    $nama_orangtua = $_POST['nama_orangtua'];
   
  

    // Insert the new 'guru' record
    $query = "INSERT INTO siswa (id_siswa ,nisn, nama_siswa, id_kelas, id_pengguna, tanggal_lahir, alamat, no_telepon, nama_orangtua) VALUES ('$id_siswa','$nisn', '$nama_siswa','$id_kelas', '$id_pengguna', '$tanggal_lahir', '$alamat', '$no_telepon', '$nama_orangtua')";
    
    if (mysqli_query($koneksi, $query)) {
        header("Location: admin.php");
        exit();
    } else {
        echo "<div class='alert alert-danger'>Error: " . mysqli_error($koneksi) . "</div>";
    }
}

ob_end_flush(); // End output buffering
?>

<style>
    .android-btn {
        display: block; /* Full width */
        padding: 15px 30px;
        font-size: 18px;
        color: #fff;
        background-color: #6200ea; /* Android Material Design color */
        border: none;
        border-radius: 25px; /* Rounded button */
        text-align: center;
        transition: background-color 0.3s ease;
        text-decoration: none;
        margin-top: 20px; /* Space above button */
    }

    .android-btn:hover {
        background-color: #3700b3; /* Darker shade on hover */
    }

    .input-field {
        padding: 12px;
        border: 1px solid #ccc;
        border-radius: 5px; /* Rounded edges */
        font-size: 16px;
        margin-bottom: 15px; /* Space between fields */
    }

    .container {
        padding-bottom: 100px; /* Extra padding at the bottom for the button */
    }
</style>

<div class="container mt-10">
    <h2 class="text-center mb-10">Tambah Data siswa</h2>
    <form method="POST">
        <input type="text" class="input-field" id="id_siswa" name="id_siswa" placeholder="ID siswa" required>
        <input type="text" class="input-field" id="nisn" name="nisn" placeholder="Nisn" required>
        <input type="text" class="input-field" id="nama_siswa" name="nama_siswa" placeholder="Nama siswa" required>
        <input type="text" class="input-field" id="id_kelas" name="id_kelas" placeholder="Kelas" required>
        <input type="text" class="input-field" id="id_pengguna" name="id_pengguna" placeholder="pengguna" required>
        <input type="text" class="input-field" id="Tanggal_lahir" name="tanggal_lahir" placeholder="Tanggal_lahir" required>
        <input type="text" class="input-field" id="alamat" name="alamat" placeholder="Alamat" required>
        <input type="text" class="input-field" id="no_telepon" name="no_telepon" placeholder="No_telepon" required>
        <input type="text" class="input-field" id="nama_orangtua" name="nama_orangtua" placeholder="Nama orang tua" required>
        <button type="submit" class="android-btn">Tambah</button> <!-- Updated button -->
    </form>
</div>

<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
