Guest User

Untitled

a guest
Dec 4th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. $(document).ready(function(){
  2. $('#form').submit(function(){
  3. $.ajax({
  4. type: 'POST',
  5. url: 'ajax/login.php',
  6. dataType: 'text',
  7. data: $('#form').serialize(),
  8. traditional: true,
  9. success: function(response) {
  10. if (response == 'yes') {
  11. $("#oKmessage").fadeIn(1000);
  12. $("#form").hide(1000);
  13. window.location.reload();
  14. } else if (response == 'no') {
  15. $("#nomessage").fadeIn(1000);
  16. $("#form").hide(1000);
  17. } else
  18. $("#emptymessage").fadeIn(1000);
  19. $("#form").hide(1000);
  20. },
  21. error: function(response) {
  22. /* ошибка соединения с интернетом */
  23. }
  24. });
  25. return false;
  26. })
  27.  
  28. });
  29.  
  30.  
  31. <?php
  32. require "../core.php";
  33.  
  34. if (isset($_POST["username"]) && isset($_POST["password"])) {
  35. if ($_POST["username"] != '' or $_POST["password"] != '') {
  36.  
  37. $username = mysqli_real_escape_string($connect, $_POST["username"]);
  38. $password = hash('sha256', $_POST["password"]);
  39. $check = mysqli_query($connect, "SELECT username, password FROM
  40. `players` WHERE `username`='$username' AND password='$password'");
  41. if (mysqli_num_rows($check) > 0) {
  42. session_start();
  43. $_SESSION['username'] = $username;
  44. $autch = 'yes';
  45. } else {
  46. $autch = 'no';
  47. }
  48. echo $auth;
  49. }
  50.  
  51. }
  52.  
  53. ?>
  54.  
  55. if (isset($_POST["signin"])) {
Add Comment
Please, Sign In to add comment