<?php

require_once './connection.php';

if (!isset($_POST['username']) == "") {
    $username = $_POST['username'];
    $password = $_POST['password'];
//    echo '$district_id '.$district_id;
    $result = array();

//    $sql = 'select tsu.*,ts.school_name,tv.village,tv.village_guj from tbl_school_user as tsu left join tbl_school as ts on tsu.school_id=ts.id LEFT join tbl_village as tv on ts.village_id=tv.id where tsu.username="'.$username.'" and tsu.password="'.$password.'" and tsu.flag="1" ORDER by tsu.id ASC';
//echo 'query ' . $sql;
    
    $sql='SELECT * FROM `tbl_user` WHERE username="'.$username.'" and password="'.$password.'"';
    try {
        if ($con) {
            mysqli_set_charset($con, 'utf8');
            $response = mysqli_query($con, $sql);
//        print_r($response);
            if (mysqli_num_rows($response) > 0) {

                while ($row = mysqli_fetch_assoc($response)) {
                    $index["id"] = $row["id"];
                    $index["username"] = $row["username"];
                    $index["password"] = $row["password"];
                    $index["name"] = $row["name"];

                    array_push($result, $index);
                }
//            $result["success"] = "1";
                echo json_encode($result);
            } else {
                echo 'User_Not_Found';
            }
        } else {
            echo 'Connection Problem';
        }
    } catch (Exception $ex) {
        echo $e->getMessage();
    }
} else {
    echo 'District ID Not Set';
}
?>
