<?


session_start();

$username=$_SESSION['user'];
$brcode=$_SESSION['brcode'];
$level=$_SESSION['level'];


  $subgname=$_REQUEST['subgname'];
  $ungrp=$_REQUEST['ungrp'];
  
 if(strlen($subgname)<=0)
  {
    print "<script> alert('Insufficient Entry'); history.back(1); </script>";
    return;
  }
 if(strlen($ungrp)<=0)
  {
    print "<script> alert('Insufficient Entry'); history.back(1); </script>";
    return;
  }

$code=substr($subgname,0,3).substr(time(),7,3);
$code=str_replace(' ','-',$code);
 include("opendb.php");
  $result=mysqli_query($db,"select * from hsnmast where head='$subgname' and brcode='$brcode'");
   if(mysqli_num_rows($result)>0)
  {
    print "<script> alert('Duplicate Entry'); history.back(1); </script>";
    return;
  }

$sql="insert into hsnmast values('$subgname','$ungrp','$brcode')";
 mysqli_query($db,$sql) or die(mysqli_error($db));
 include('hsnmast.php');
?>
