How to validate user if input end date is more than 3 days from the input start date?
Given: PHP Code
if(isset($_POST['btnRequest']))
{
$leaveFrom = $_POST['leaveFrom'];
$leaveTo = $_POST['leaveTo'];
}
$sql_insert = "INSERT INTO leaves (leaveFrom, leaveTo) VALUES (?, ?)";
HTML Code
<input type="date" id="leaveFrom" name="leaveFrom" class="form-control" required="true" />
<input type="date" id="leaveTo" name="leaveTo" class="form-control" required="true" />
Data types are 'date' from Microsoft SQL
Goal: To submit date if date ranges to 3 days or less.
(This is for a user who can file his/her 'Sick Leave' to the admin with a limit of 3 days of leave)
I tried Zain Farooq's code but here's what I tried.
function fourDays()
{
return date("Y-m-d"),strtotime("+ 4days"));
}
$date = date('Y-m-d'),strtotime($leaveTo)); // I want to
validate the input from the input 'leaveFrom' but I have no idea how
if($date >= fourdays())
{
$dispMsg = $dateerrorMsg;
}