<?php 
 echo @$_GET['msg'];
  // session_start();
  // if(isset($_SESSION['userId'])){ 
if(isset($_POST['grpname'])){
extract($_POST);
if($grpname==''){
	echo "Please Enter Group Name";
}
	else
	{
	$grpname=strtoupper($grpname);

                    require 'connection.php'; 

  $qry = "SELECT groupname FROM groupreg where groupname='$grpname'";
   $run = mysqli_query($connect, $qry) or die(mysqli_error($connect));
   $row = mysqli_fetch_array($run);
   $fetgrpname=$row['groupname'];
   if($fetgrpname==$grpname){
   	echo "This group name already exist ! ";
   }
   else{

$supname="SELECT max(groupid) as groupid from groupreg";
	$suprun=mysqli_query($connect,$supname) or die(mysqli_error($connect));
	$suprow=mysqli_fetch_array($suprun);
	$groupid= $suprow['groupid']+1;
	
	 $stockqty="INSERT INTO `groupreg`(`groupid`,`groupname`,`chartid`, `grouptype`) VALUES('$groupid','$grpname','$chrtid','$grptype')";
	$stockresult=mysqli_query($connect,$stockqty) or die(mysqli_error($connect));

echo "Group created....";
   }


}

}
// }

?>
