<?php
    require_once("../models/user.php");

    $user=new user();

    if(isset($_POST['loginuser'])){
        $username=$_POST['username'];
        $password=$_POST['password'];
        $database=$_POST['database'];
        echo $user->loginuser($database,$username,$password);
    }

    if(isset($_GET['logoff'])){
        session_destroy();
        //redirect to the login page
        header('Location: ../index.php'); 
    }

    if(isset($_GET['getloggedinuser'])){
        echo json_encode($_SESSION['username']);
    }
?>