<?
include_once('includes/top.php');
include_once('opendb.php');
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
//$br=$_SESSION['branch'];
if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='inde.php' </script>";
  return;
}
$gname=$_REQUEST['gname'];
$nature=$_REQUEST['nature'];
$level=$_REQUEST['level'];
if(strlen($gname)<=0)
{	
	print "<font face=verdana color=red>Insufficient Data".$gname."</font>";
	include("acgroup.php");
 	return;
}
$result=mysqli_query($db,"select * from acgroups where gname='$gname'");
if(mysqli_num_rows($result)>0)
{
 print "<script> alert('Group already exits'); history.back(1); </script>";
// include("acgroup.php");
 return;
}
$result=mysqli_query($db,"select * from acgroups where nature='$nature' and level='$level'") or die(mysqli_error($db));
if(mysqli_num_rows($result)>0)
{
 print "<script> alert('Level has already been defined'); history.back(1); </script>";
 return;
}

 $sql="insert into acgroups(gname,nature,level) values('$gname','$nature','$level')";
 mysqli_query($db,$sql) or die(mysqli_error($db));
include("acgroup.php");
?>
