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