<?php
	include('db.php');
// Check connection
if ($con->connect_error) {
    die("Connection failed: " . $con->connect_error);
}

$username=$_GET["name"];
$password=$_GET["pass"];
$sql = "SELECT * FROM `tbl_users` where registration_id = '$username' AND login = '$password' OR email = '$username' AND login = '$mypassword' OR first_name = '$myusername' AND login = '$password'";
$result = $con->query($sql);

if ($result->num_rows > 0) {
 
    $items = array();
    // output data of each row
    while($row = $result->fetch_assoc()) 
	{
        $item = array("user_id" => $row['registration_id'],
                                         "Role" => $row['role'],
					  "lastname" => $row['last_name'],
					  "gender" => $row['role'],
					  "dob" => $row['dob'],
					  "address" => $row['address'],
					  "email" => $row['email'],
					  "phone" => $row['phone'],
					  "department" => $row['department'],
					  "category" => $row['category'],
					  "login" => $row['login'],  
					  "avatar" => $row['avatar']
					 );

    }
	$message=$item;
	$response=array('status' => "true", 'Message' => "Login success",'Login_details' => $message);  
            echo json_encode($response);
	
	} 
	else 
	{
     $response=array('status' => "false", 'Message' => "Login Failed");
            echo json_encode($response);
	}
$con->close();
?> 