<?
include("opendb.php");
if(strlen($grp)<=0)
{
 print"<script>alert('Insufficient Entry'); history.back(1); </script>";
 return;
}
$code=substr($grp,0,3).substr(time(),7,3);
$code=str_replace(' ','-',$code);
$result=mysqli_query($db,"select * from opgrp where gname='$grp'");
if(mysqli_num_rows($result)>0)
{
 print"<script>alert('Duplicate Entry'); history.back(1); </script>";
 return;
}
$sql="insert into opgrp values('$code','$grp')";
mysqli_query($db,$sql)or die(mysqli_error()); 
 print"<script> document.location='opmas.php' </script>";
?>
