Advertisement
Guest User

Untitled

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