<?php
include('connect.php');

$DateFrom = $_POST["date4"];
$DateTo = $_POST["date5"];
$Hour = $_POST["hours"];
$LeaveType = $_POST["type"];
$Reason = $_POST["reason"];

if(($DateFrom == "")||($DateTo == "")||($Hour == "")||($LeaveType == "")||($Reason == "")){
	echo "<script>alert('Please fill in your form completely')</script>";
	echo "<script language='javascript'>window.location='leaveform.php'</script>";

}else{
$query = "INSERT INTO leaveform(DateFrom, DateTo, Hours, LeaveType, Reason)VALUES('$DateFrom', '$DateTo', '$Hour', '$LeaveType', '$Reason')";
$result = $db->query($query);					
		$db->close();
		echo "<script language='javascript'>alert('Apply Leave Successful.')</script>";
		echo "<script language='javascript'>window.location='adminaccount.php'</script>";
}
?>