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

$str=" ";
//$name= trim($_POST['name']);
$uname= trim($_POST['uname']);
$password= trim($_POST['password']);
$password1= trim($_POST['password1']);
$alevel= trim($_POST['alevel']);
//$loc_id= trim($_POST['branch']);
$emp= trim($_POST['emp']);
//$emp1= trim($_POST['emp1']);
//$st1= trim($_POST['st1']);
//$st2= trim($_POST['st2']);
//$dept= trim($_POST['dept']);
//$au1= trim($_POST['au1']);


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


if ($password<>$password1){
    echo "<script type='text/javascript'>alert('Password Error!');</script>";
	echo "<script>document.location='usermgt_user.php'</script>"; 

}


$query=mysqli_query($con," select * from users_master where username='$uname'  ")or die(mysqli_error($con));
$count=mysqli_num_rows($query);
if ($count>0)
{
	echo "<script type='text/javascript'>alert('Exsisting User!');</script>";
	echo "<script>document.location='usermgt_user.php'</script>"; 
}

else {

		if ( mysqli_query($con,"INSERT INTO users_master(username,password,Active,al,edate,emp_id) 
		VALUES('$uname','$password',1,'$alevel','$edate',$emp)  ")or die(mysqli_error($con)))
	        {
					
				//echo "<script type='text/javascript'>alert('Successfully added New Category!');</script>";staff1_id,staff2_id
				echo "<script>document.location='usermgt_user.php'</script>"; 
	     	 
			}
}		

?>