<?php
include 'config/koneksi.php';

$nama = $_POST['nama'];
$nisn = $_POST['nisn'];
$asal = $_POST['asal_sekolah'];
$jurusan = $_POST['jurusan'];
$hp = $_POST['no_hp'];
$alamat = $_POST['alamat'];

$foto_kk = $_FILES['foto_kk']['name'];
$tmp_kk  = $_FILES['foto_kk']['tmp_name'];

// FOTO KTP
$foto_ktp = $_FILES['foto_ktp']['name'];
$tmp_ktp  = $_FILES['foto_ktp']['tmp_name'];

// FOTO AKTE
$foto_akte = $_FILES['foto_akte']['name'];
$tmp_akte  = $_FILES['foto_akte']['tmp_name'];


// Upload file
move_uploaded_file($tmp_kk, "assets/img/kk/" . $foto_kk);

move_uploaded_file($tmp_ktp, "assets/img/ktp/" . $foto_ktp);

move_uploaded_file($tmp_akte, "assets/img/akte/" . $foto_akte);

mysqli_query($conn,"INSERT INTO pendaftar
VALUES(
NULL,
'$nama',
'$nisn',
'$asal',
'$jurusan',
'$hp',
'$alamat',
'$foto_kk',
'$foto_ktp',
'$foto_akte',
NOW()
)");

echo "
<script>
alert('Pendaftaran berhasil');
window.location='index.php';
</script>
";
?>