Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
509
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. <?php
  2.  
  3. include 'connection.php';
  4. $error='';
  5. // array for JSON response
  6. $response = array();
  7.  
  8. if (isset($_POST['nim']) && isset($_POST['password'])){
  9. if (empty($_POST['nim']) || empty($_POST['password'])) {
  10. // required field is missing
  11. $response["success"] = 0;
  12. $response["message"] = "Data Tidak Lengkap";
  13.  
  14. // echoing JSON response
  15. echo json_encode($response);
  16. }else{
  17. $nim=$_POST['nim'];
  18. $password=$_POST['password'];
  19. $query = "select * from user where password='$password' AND nim='$nim'";
  20. $sql = mysqli_query($con, $query);
  21. $rows = mysqli_fetch_array($sql);
  22. if ($rows) {
  23. // required field is missing
  24. $response["success"] = 1;
  25. $response["message"] = "Berhasil Login";
  26.  
  27. // echoing JSON response
  28. echo json_encode($response);
  29. } else {
  30. // required field is missing
  31. $response["success"] = 0;
  32. $response["message"] = "Username atau Password Salah";
  33.  
  34. // echoing JSON response
  35. echo json_encode($response);
  36. }
  37. }
  38. }else {
  39. // required post params is missing
  40. $response["success"] = 0;
  41. $response["message"] = "Kesalahan pada data anda";
  42. echo json_encode($response);
  43. }
  44. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement