<?php 
 echo @$_GET['msg'];
  // session_start();
  // if(isset($_SESSION['userId'])){ 
if(isset($_POST['itmname'])){
extract($_POST);
if($itmname==''){
	echo "Please Enter Product Name";
}
	else
	{
	$itmname=strtoupper($itmname);
$dated=date("Y/m/d");

                    require 'connection.php'; 

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

$supname="SELECT max(itemid) as itemid from itemreg";
	$suprun=mysqli_query($connect,$supname) or die(mysqli_error($connect));
	$suprow=mysqli_fetch_array($suprun);
	$itemid= $suprow['itemid']+1;
	
	 $stockqty="INSERT INTO `itemreg`(`dated`,`itemid`,`itemcode`, `itemname`, `rate`, `srate`, `ministock`, `catid`) VALUES('$dated','$itemid','$itemid','$itmname','$prate','$srate','$ministock','$catid')";
	$stockresult=mysqli_query($connect,$stockqty) or die(mysqli_error($connect));

echo "Product created....";
   }


}

}
// }

?>
