<?php
require_once("conf.php");
require_once("method.php");

$method = $_SERVER["REQUEST_METHOD"];
method($method);

$data = json_decode(file_get_contents('php://input'), true);

if ($method == "POST") {
    if ($data['prlEmail'] != null && $data['prlPassword'] != null) {
        $query = $db->query("SELECT * FROM personel WHERE prlEmail = '" . $data['prlEmail'] . "' AND prlPassword='" . $data['prlPassword'] . "' AND prlIsEnabled ='1' ", PDO::FETCH_ASSOC);
        if ($query->rowCount() == 1) {
            foreach ($query as $q) {
                $personel[] = array(
                    "prlId" => $q["prlId"],
                    "prlName" => $q["prlName"],
                    "prlLastName" => $q["prlLastName"],
                    "prlPhone" => $q["prlPhone"],
                    "prlEmail" => $q["prlEmail"],
                    "prlPassword" => $q["prlPassword"],
                    "prlYetki" => $q["prlYetki"],
                    "prlUserYetki" => $q["prlUserYetki"],
                    "prlIsEnabled" => $q["prlIsEnabled"],
                    "prlCreatedAt" => $q["prlCreatedAt"]
                );
            }
            $result = json_encode($personel, JSON_UNESCAPED_UNICODE);
            echo $result;
        } else {
            echo json_encode('validate error');
        }
    } else {
        echo json_encode('error');
    }
}
