<?php
	//Connects to your Database
	include "../db_connection/db_connection.php";
	include "../config/config.php";		
	                    
	
		
		$dept_name		=	trim($_POST['dept_name']); 
		
		$SLCT_comp = "SELECT * FROM master_dept WHERE master_dept_name='$dept_name'";
		$QURY_comp = mysqli_query($connect,$SLCT_comp);
		$res_comp = mysqli_num_rows($QURY_comp);
		if($res_comp==0){

		
		$INSRT		= "INSERT INTO master_dept(`master_dept_name`, `post_dt`) VALUES ('$dept_name','$cur_time')";
		$QURY		= mysqli_query($connect,$INSRT);	
		
?>
		<script type="text/javascript">
            //alert("Data inserted successfully");
            //history.back();
            window.location='../master_dept_list.php';
        </script>
		
		<?php } else { ?>
		<script type="text/javascript">
            alert("Department Name Already exists!!");
            //history.back();
            window.location='../master_dept_add.php';
        </script>

		
		
		<?php } ?>
		
	
