<?php
require 'koneksi.php';
$con = open_connection();

if(isset($_POST['simpan'])){

    $nama = $_POST['nama'];
    $nip = $_POST['nip'];
    $username = $_POST['username'];
    $password = $_POST['password'];
    $no_hp = $_POST['no_hp'];

    mysqli_query($con,"
        INSERT INTO guru
        (nama,nip,username,password,no_hp)
        VALUES
        ('$nama','$nip','$username','$password','$no_hp')
    ");

    catat_log($con, "Data guru baru ditambahkan: " . $nama, "guru");

    header("Location:guru.php");
}
?>
<?php require 'header.php';?>

<div class="container mt-4">

<h2>Tambah Guru</h2>

<form method="POST">

    <div class="mb-3">
        <label>Nama</label>
        <input type="text" name="nama" class="form-control">
    </div>

    <div class="mb-3">
        <label>NIP</label>
        <input type="text" name="nip" class="form-control">
    </div>

    <div class="mb-3">
        <label>Username</label>
        <input type="text" name="username" class="form-control">
    </div>

    <div class="mb-3">
        <label>Password</label>
        <input type="text" name="password" class="form-control">
    </div>

    <div class="mb-3">
        <label>No HP</label>
        <input type="text" name="no_hp" class="form-control">
    </div>

    <button type="submit" name="simpan" class="btn btn-success">
        Simpan
    </button>

</form>

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