<?php
    // session_start();
    // //include('config.php');
    // $uname=trim($_POST['uname']);
    // $password=trim($_POST['password']);
    
    // if($uname == "admin"){
    //     if($uname=="admin" && $password=="admin.123")
    //     {
    //         echo ("success");
    //         $_SESSION['user']= 'admin'; 
    //         $_SESSION['user_type']= '1';
    //     }
    //     else{
    //         echo "Invalid Username and/or Password";
    //         session_destroy();
    //     }
    // }
    // if($uname == "adminX"){
    //     if($uname=="adminX" && $password=="try.123")
    //     {
    //         echo ("success");
    //         $_SESSION['user']= 'adminX'; 
    //         $_SESSION['user_type']= '2';
    //     }
    //     else{
    //         echo "Invalid Username and/or Password";
    //         session_destroy();
    //     }
    // }

    header('Content-Type: application/json');

    $uname = trim($_POST['uname']);
    $password = trim($_POST['password']);

    $response = array(
        "status" => "error",
        "message" => "Invalid Username and/or Password",
        "user" => null,
        "user_type" => null
    );

    if ($uname === "admin" && $password === "admin.123") {
        $response['status'] = "success";
        $response['message'] = "Login successful";
        $response['user'] = "admin";
        $response['user_type'] = "1";
    } elseif ($uname === "adminX" && $password === "try.123") {
        $response['status'] = "success";
        $response['message'] = "Login successful";
        $response['user'] = "adminX";
        $response['user_type'] = "2";
    }

    echo json_encode($response);

?>
