<?
session_start();
if(strlen($user)<=0)
{
 print "<script> alert('You are not logged in') </script>";
 include("logout.php");
 return;
}

$entrydate=date("Y-m-d");
include("opendb.php");
$re=mysqli_query($db,"select * from labourmaster where labname='$labname'");
 if(mysqli_num_rows($re)>0)
 {
  print "<script> alert('Labour already exists'); history.back(1); </script>";
  return;
 }
$code=substr($labname,0,3).date(ymds);
$code=str_replace(' ','-',$code);

$sql1="insert into labourmaster (labcode,labname,totallcv,brcode,user,entrydate) values('$code', '$labname','$amt','$brcode','$user','$entrydate')";

mysqli_query($db,$sql1)or die('sq1 err'.mysqli_error($db));


//******************************888888888888*******************88888888





echo "<meta http-equiv='refresh' content='.1;url=labourmast.php'>";
?>
