SHARE
TWEET

Login Json php ke android

heru-kzw May 22nd, 2017 360 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. require_once"../konmysqli.php";
  3. $respon = array();
  4.  
  5. if (isset($_GET["username"])) {
  6.     $username= $_GET['username'];
  7.     $password= $_GET['password'];
  8.  
  9.     $sql="SELECT * FROM `$tbpengelola` WHERE `username` ='$username' and `password`='$password'";
  10.     $jum=getJum($conn,$sql);
  11.     if ($jum>0) {
  12.             $d=getField($conn,$sql);
  13.             $record = array();
  14.            
  15.             $kode_pengelola=$d["kode_pengelola"];
  16.             $nama_pengelola=$d["nama_pengelola"];
  17.             $alamat=$d["alamat"];
  18.             $telepon=$d["telepon"];
  19.             $username=$d["username"];
  20.             $password=$d["password"];
  21.             $keterangan=$d["keterangan"];
  22.             $status=$d["status"];
  23.  
  24.             $record["xmlbio"] = "$kode_pengelola#$nama_pengelola#$alamat#$telepon#$username#$password#$keterangan#$status";  
  25.            
  26.             $respon["sukses"] = 1;
  27.             $respon["record"] = array();
  28.            
  29.             array_push($respon["record"], $record);
  30.              $respon["pesan"] = "$jum record";
  31.             echo json_encode($respon);
  32.         } else {
  33.             $respon["sukses"] = 0;
  34.             $respon["pesan"] = "0 record";
  35.             echo json_encode($respon);
  36.         }
  37.  
  38. } else {
  39.     $respon["sukses"] = 0;
  40.     $respon["pesan"] = "? lengkapi data";
  41.     echo json_encode($respon);
  42. }
  43. ?>
  44.  
  45. <?php
  46.  
  47. function getJum($conn,$sql){
  48.   $rs=$conn->query($sql);
  49.   $jum= $rs->num_rows;
  50.     $rs->free();
  51.     return $jum;
  52. }
  53.  
  54. function getField($conn,$sql){
  55.     $rs=$conn->query($sql);
  56.     $rs->data_seek(0);
  57.     $d= $rs->fetch_assoc();
  58.     $rs->free();
  59.     return $d;
  60. }
  61. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top