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

$str=" ";
$empname=" ";
$empname= trim($_POST['emp']);
$address= trim($_POST['address']);
$tel= trim($_POST['tel']);
$email= trim($_POST['email']);
$loc_id=trim($_POST['loc_id']);
$e_id=trim($_POST['e_id']);
$edate=date("Y-m-d");
$userid=$_SESSION['rm_id'];
$repcode=trim($_POST['repcode']);


if (empty($empname)) {
    
    echo "<script type='text/javascript'>alert('Please Enter employee Name!');</script>";
	echo "<script>document.location='admin_emp.php'</script>"; 
}

else {
$query=mysqli_query($con," select * from employee_master where emp_name='$empname'  ")or die(mysqli_error($con));
    $count=mysqli_num_rows($query);
if ($count>0)
{
	echo "<script type='text/javascript'>alert('Exsisting Employee!');</script>";
	echo "<script>document.location='admin_emp.php'</script>"; 
}

else {
//$pp="INSERT INTO employee_master(emp_name,Address1,mobile,email,emp_Active,e_id,edate,userid) 
			                               //  VALUES('$empname','$address','$tel','$email',1,$e_id,'$edate',$userid) ";
			                             
		if ( mysqli_query($con,"INSERT INTO employee_master(emp_name,Address1,mobile,email,emp_Active,e_id,edate,userid) 
			                                 VALUES('$empname','$address','$tel','$email',1,$e_id,'$edate',$userid)  ")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_emp.php'</script>"; 
	     	 
			}
}	

}

?>