<?
include("opendb.php");
if(strlen($item)<=0 || strlen($opgrp)<=0)
{
 print "<script> alert('Insufficient Entry'); history.back(1); </script>";
 return;
}
$code=substr($item,0,3).substr(time(),7,3);
$code=str_replace(' ','-',$code);
$code=str_replace('&','-',$code);

$result=mysqli_query($db,"select * from opitem where itemname='$item'");
if(mysqli_num_rows($result)>0)
{
 print"<script>alert('Duplicate Entry'); history.back(1); </script>";
 return;
}
$sql="insert into opitem values('$code','$opgrp','$item','$amt')";
mysqli_query($db,$sql)or die(mysqli_error()); 
 print"<script> document.location='opmas.php' </script>";
?>
