<?php
       
	    //include('admin/lib/dbcon.php');
		include('admin/lib/conn.php');
		//dbcon(); 
		session_start();
			$username =isset($_POST['username']) ? strtolower($_POST['username']) : NULL;
			$password =isset($_POST['password']) ? strtolower($_POST['password']) : NULL;	

		/*................................................ admin .....................................................*/
			$query = "SELECT * FROM admin WHERE username='$username' AND password='$password'";
			$result = mysqli_query($con,$query);
			//$result = mysql_query($query)or die(mysql_error());
			$row = mysqli_fetch_array($result, MYSQLI_BOTH);
			$num_row = mysqli_num_rows($result);
			
			
		/*...................................................Technical Staff ..............................................*/
		$query_client = mysqli_query($con,"SELECT * FROM client WHERE username='$username' AND password='$password'");
		$num_row_client = mysqli_num_rows($query_client);
		$row_client = mysqli_fetch_array($query_client);
		
		if( $num_row > 0 ) { 
		$_SESSION['id']=$row['admin_id'];
		echo 'true_admin';
		
		mysqli_query($con,"insert into user_log (username,login_date,admin_id)values('$username',NOW(),".$row['admin_id'].")");
		
		}else if ($num_row_client > 0){
		$_SESSION['client']=$row_client['client_id'];
		echo 'true';
		
		mysqli_query($con,"insert into user_log (username,login_date,client_id)values('$username',NOW(),".$row_client['client_id'].")");
		
		 }else{ 
				echo 'false';
		}	
				
		?>