Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $response = array();
- // include db connect class
- require_once __DIR__ . '/db_connect.php';
- // connecting to db
- $db = new DB_CONNECT();
- if (isset($_GET["Username"], $_GET["Password"])) {
- $user = $_GET['Username'];
- $pass = $_GET['Password'];
- $result = mysql_query ("
- select
- id,
- username,
- password,
- hak_akses,
- kode
- from User
- where username = '$user'
- and password = '$pass'") or die(mysql_error());
- // check for empty result
- if (mysql_num_rows($result) > 0) {
- $response["Hasil"] = array();
- $row=0;
- while ($row = mysql_fetch_array($result)){
- $product = array();
- $product["ID"] = $row["id"];
- $product["Username"] = $row["username"];
- $product["Password"] = $row["password"];
- $product["HakAkses"] = $row["hak_akses"];
- $product["Kode"] = $row["kode"];
- // push single product into final response array
- array_push($response["Hasil"], $product);
- }
- // success
- $response["success"] = 1;
- // echoing JSON response
- echo json_encode($response);
- } else {
- // no Hasil found
- $response["success"] = 0;
- $response["message"] = "Hasil Tidak Ditemukan";
- // echo no users JSON
- echo json_encode($response);
- }
- } else {
- // Hasil Tidak Di Ditemukan
- $response["success"] = 0;
- $response["message"] = "Hasil Tidak Di Ditemukan";
- // Menampilkan Respon JSON
- echo json_encode($response);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement