Advertisement
Guest User

Untitled

a guest
Jul 19th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. rules: {
  2.  
  3. username: {
  4. required: true
  5. },
  6. password: {
  7. required: true
  8. }
  9. },
  10. messages: {
  11. //etc
  12. },
  13. submitHandler: function(form) {
  14.  
  15. $.ajax({
  16. type: "POST",
  17. url: 'php/login.php',
  18. data: $('form').serialize(),
  19.  
  20. success: function(data) {
  21.  
  22. console.log(data);
  23. if (data === "1")
  24. {
  25. console.log("username and password matched with database");
  26. } else
  27. {
  28. console.log("invalid username or password");
  29. }
  30. }
  31. });
  32. return false;
  33. }
  34. });
  35.  
  36. include 'php/database.php';
  37.  
  38. $username = $_POST['username'];
  39. $password = $_POST['password'];
  40.  
  41. $sql = "SELECT * FROM login WHERE username='$username' AND password='$password'";
  42. $result = $conn->query($sql);
  43.  
  44. if ($result->num_rows > 0)
  45. {
  46. echo true;
  47. } else
  48. {
  49. echo false;
  50. }
  51.  
  52. <?php
  53.  
  54. $username = $_POST['username'];
  55. $password = $_POST['password'];
  56.  
  57. if($username === "bob" && $password === "123")
  58. {
  59. echo true;
  60. }else
  61. {
  62. echo false;
  63. }
  64. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement