<?
if(strlen($y)>4 || strlen($y)<4||strlen($y1)>4 || strlen($y1)<4)
{
 print "<script>alert('Invalid Year'); history.back(1);</script>";
 return;
}

if(!checkdate($m,$d,$y))
{
 print "<script>alert('Invalid Date'); history.back(1);</script>";
 return;
}

if(!checkdate($m1,$d1,$y1))
{
 print "<script>alert('Invalid Date'); history.back(1);</script>";
 return;
}

include("opendb.php");
$df=$y.'-'.$m.'-'.$d;
$dt=$y1.'-'.$m1.'-'.$d1;

 $sssq="select to_days('$df')-to_days('$dt')";
//print $sssq;
$dtcheck2=mysqli_query($db,$sssq) or die(mysqli_error());
 $dtrow2=mysqli_fetch_row($dtcheck2) or die(mysqli_error());
// print $dtrow2[0].','.$dtrow2[1];
 if($dtrow2[0]>0)
 {
   print "<script>alert('Invalid date, Check a/c Period'); history.back(1);</script>";
   return;
 }


$sql="update acperiod set acfrom='$df',acto='$dt'";
mysqli_query($db,$sql) or die(mysqli_error());
print "<font color=green>Data has been saved</font>";
include("period.php");
?>
