<?php 
session_start();
include('../includes/dbcon.php');

$str=" ";

//$lname= trim($_POST['lname']);
$catname= trim($_POST['catname']);


$edate=date("Y-m-d");
$userid=$_SESSION['rm_id'];



$query=mysqli_query($con," select * from item_category where cat_des='$catname'  ")or die(mysqli_error($con));
    $count=mysqli_num_rows($query);
if ($count>0)
{
	echo "<script type='text/javascript'>alert('Exsisting Category!');</script>";
	echo "<script>document.location='admin_cat_view.php'</script>"; 
}

else {

		if ( mysqli_query($con,"INSERT INTO item_category(cat_des,cat_active) 
			                                 VALUES('$catname',1)  ")or die(mysqli_error($con)))
	        {
					
				//echo "<script type='text/javascript'>alert('Successfully added New Category!');</script>";staff1_id,staff2_id
				echo "<script>document.location='admin_cat_view.php'</script>"; 
	     	 
			}
}		

?>