<?php
if($_POST["dosage"] && $_POST["patientID"] &&$_POST["iname"] && $_POST['user'] && $_POST['sdate'] )
{     
  //CHECKING ENDS HER
  require_once"labClass.php";
  $con=new labClass();
  $iname = $_POST["iname"];
  $Q= $con->getThisItem($iname);
  if($Q->rowCount()>0)
    { 
    $iq=$Q->fetch(); 
    $isprice= $iq['isprice']; 
    $user= $_POST['user'];
    $iQty= 0;
    $patientID= $_POST['patientID']; 
    $sdate= $_POST['sdate'];
    $dosage= $_POST['dosage'];
    $gt= $con->getThisDosage($patientID,$iname,$sdate);
    if($gt->rowCount()<=0)
    {
    $in= $con->dosageReg($patientID,$iname,$dosage,$isprice,$iQty,$sdate,$user);
    if($in->rowCount()>0)
    {
      ?>
      <h6 class="text-success">Saved!..</h6> 
      <?php
      }
  else{
       ?>
        <h6 class="text-danger">Item does not exist!..</h6>
       <?php
       }
          }
  else{
       ?>
        <h6 class="text-danger">Same dosage exist!..</h6>
       <?php
       }
       }
  else{
       ?>
        <h6 class="text-danger">Item does not exist!..</h6>
       <?php
       }
       }
  else{
       ?>
       <h6 class="text-danger">All field required!..</h6>
       <?php
    }
?>