<?
session_start();
if(strlen($gname)<=0)
{
 print "<font face=verdana color=red>Insufficient Data</font>";
 include("acgroup.php");
 return;
}
include("opendb.php");
$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());
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());
include("acgroup.php");
?>
