<?php
include "koneksi.php";
if(isset($_POST['username']) && isset($_POST['password'])){
  $id_administrator = "";
  $username = $_POST['username'];
  $password = $_POST['password'];
  $query=mysqli_query($koneksi, "SELECT * FROM administrator WHERE username='".$username."' LIMIT 1");
  $output = array();
  if($row = mysqli_fetch_assoc($query)){
    if($row['password']==""){
      $output['id_administrator'] = -2;
      echo json_encode($output);
    } else {
      if($password==$row['password']){
        $output['id_administrator'] = $row['id_administrator'];
        $output['nama_administrator'] = $row['nama_administrator'];
        $output['username'] = $row['username'];
        $output['password'] = $row['password'];
        //$output['jabatan'] = $row['jabatan'];
        echo json_encode($output);
      } else {
        $output['id_administrator'] = -1;
        echo json_encode($output);
      }
    }
  } else {
    $output['id_administrator'] = 0;
    echo json_encode($output);
  }
} else {
  $output['id_administrator'] = 0;
  echo json_encode($output);
}
?>
