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

$str=" ";

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


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



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

else {

		if ( mysqli_query($con,"INSERT INTO unit_master(unit_des,unit_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_unit_view.php'</script>"; 
	     	 
			}
}		

?>