<?php
session_start();
$server = "localhost";
$username = "root";
$password = "";
$database = "simpodik";
//$database = "spp_dummy";
include "config/variabel_default.php";
mysqli_connect($server, $username, $password);
mysqli_select_db($database);
$nama_file = time() . '.jpg';
$direktori = './foto_absen/';
$target = $direktori . $nama_file;
$id = $_SESSION[ids];
$tanggal = date("Y-m-d");
$name       = $_POST['jdwl'];
$latitude = $_GET['lokasi'];
if (move_uploaded_file($_FILES['webcam']['tmp_name'], $target)) {
    mysqli_query($conn,"insert into rb_absen set nama='$nama_file', nisn='$id', tanggal='$tanggal',waktu='$waktu_sekarang',kode_kehadiran='H',kodejdwl='$name',lokasi='$latitude'");
} else {
    // Jika Gagal, Lakukan :
    echo "<div class='alert alert-danger alert-dismissible fade in' role='alert'> 
					<button type='button' class='close' data-dismiss='alert' aria-label='Close'>
					<span aria-hidden='true'>×</span></button> <strong>Maaf!</strong> - Terjadi kesalahan saat input data,..
					</div>";
    echo "<br><a href='form.php'>Kembali Ke Form</a>";
};
