<?php 

include("config.php");

 
 



$cdate=dtformat($_POST[cdate]);
$cdate2=dtformat($_POST[cdate2]);
 $user_ip = getUserIP();
 
 
$timestamp1 = strtotime($cdate);
$timestamp2 = strtotime($cdate2);

// Difference in days
$leave_days = ceil(abs($timestamp2 - $timestamp1) / (60 * 60 * 24));
 
$leave_days=$leave_days+1;
 
 
mysql_query("INSERT INTO hr_leave ( employee, cdate, cdate2, commentx,suser,user_ip,leave_days) VALUES (  '$_POST[employee]','$cdate','$cdate2','$_POST[commentx]' ,'$_SESSION[uid]','$user_ip','$leave_days')");
	

header("location:hr_leave.php");
?>