<?
session_start();
include_once('opendb.php');
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];

if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='inde.php'; </script>";
 return;
}
$led=$_REQUEST['led'];
$grp=$_REQUEST['grp'];
$opb=$_REQUEST['opb'];
$drcr=$_REQUEST['drcr'];
$code=$_REQUEST['code'];
//$sql="update ledger set grp='$grp',op='$opb',drcr='$drcr' where led='$led' and brcode='$brcode'";
//mysqli_query($db,$sql) or die(mysqli_error($db));
//log_entry($brcode,$user,$REMOTE_ADDR,"ledger update: $led");

$re11=mysqli_query($db,"select * from ledger where led='$led' and brcode='$brcode'");
	if(mysqli_num_rows($re11)>0)
	{
		 print "<script>alert('Duplicate Entry'); history.back(1); </script>";
		 return;
	}

$sql="insert into ledger(led,grp,op,drcr,code,brcode) values('$led','$grp','$opb','$drcr','$code','$brcode')";
	mysqli_query($db,$sql) or die(mysqli_error($db));
	
print "<script> alert('data saved');parent.document.location='sealedgall.php';window.close(); </script>";
?>

