Advertisement
Guest User

Untitled

a guest
Apr 20th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. function cek(){
  2. var username = $("#username").val();
  3. var password = $("#password").val();
  4.  
  5. if (username == "" && password == "") {
  6. alert("Username and password can't be empty!");
  7. }else {
  8. $.ajax({
  9. url: "processLogin.php",
  10. type: "POST",
  11. data:{
  12. username: $("#username").val(), password: $("#password").val()
  13. },
  14. success:function(e){
  15. alert("e");
  16. }
  17. });
  18. }
  19. }
  20.  
  21. $username = $_POST['username'];
  22. $password = $_POST['password'];
  23.  
  24. $sql = "SELECT * FROM user WHERE nama='$username' AND password='$password'";
  25. $query = $db->query($sql)or die(mysqli_error($db));
  26. $result = $query->fetch_assoc();
  27.  
  28. if ($query->num_rows == 0) {
  29.  
  30. // I want this to be show on alert
  31. echo "Username not found!";
  32.  
  33. }else{
  34. if ($password <> $result['password']) {
  35.  
  36. // I want this to be show on alert
  37. echo "Incorrect password!";
  38.  
  39. }else{
  40. $_SESSION['username'] = $result['nama'];
  41. $_SESSION['tipe'] = $result['tipe'];
  42. header('location:index.php');
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement