Advertisement
karlokokkak

Untitled

Mar 28th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. <?php
  2.     include 'connectdb.php';
  3.  
  4.     $data = json_decode(file_get_contents('php://input'), true);
  5.  
  6.     $kodeDosen =$data["kodeDosen"];
  7.     $password = $data["password"];
  8.  
  9.     $message = array("message"=>"Data found");
  10.     $failure = array("mesage"=>"Data not found");
  11.  
  12.     if ($stmt = mysqli_prepare($conn, "SELECT kodeDosen, namaDosen, email, telepon FROM tbl_dosen WHERE kodeDosen =? and password = ?")) {
  13.  
  14.        /* bind parameters for markers */
  15.        mysqli_stmt_bind_param($stmt, "ss", $kodeDosen,$password);
  16.  
  17.        /* execute query */
  18.        mysqli_stmt_execute($stmt);
  19.  
  20.        /* store result */
  21.        $result = mysqli_stmt_get_result($stmt);
  22.        $row = mysqli_fetch_assoc($result);
  23.  
  24.        if(mysqli_num_rows($result) > 0) {
  25.           echo json_encode($row);
  26.        }else {
  27.           echo json_encode($failure);
  28.        }
  29.  
  30.     }
  31.  
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement