MyBlogShare

Proses Login PHP

Jul 5th, 2021
2,135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. <?php
  2.     require "koneksi.php";
  3.     $nama = $_POST['username'];
  4.     $pass = $_POST['password'];
  5.    
  6.     $query = "SELECT * from table_login where username = '$nama' AND password = '$pass';";
  7.     $result = mysqli_query($conn, $query);
  8.     $row = mysqli_fetch_array($result);
  9.  
  10.     if (mysqli_num_rows($result) > 0) {
  11.         $response = array();
  12.         $code = "login_true";
  13.         $message = "Welcome to Apps My Application.";
  14.         array_push($response, array("code"=>$code, "pesan"=>$message));
  15.         echo json_encode(array("Server"=>$response));
  16.     }else{
  17.         $response = array();
  18.         $code = "login_false";
  19.         $message = "Maaf data anda belum terdaftar..!";
  20.         array_push($response, array("code"=>$code, "pesan"=>$message));
  21.         echo json_encode(array("Server"=>$response));
  22.     }
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment