Guest User

Untitled

a guest
Oct 15th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. <script type="text/javascript">
  2. $(document).ready(function(){
  3. $('#btnLogin').bind('click', loginToWebsite);
  4. });
  5. function loginToWebsite(){
  6. $.ajax({
  7. url: "login.php",
  8. type: "POST",
  9. data: "username=" + $("#username").val()+"&password=" + $("#password").val(),
  10. datatype:"json",
  11. success: function(status)
  12. {
  13. if(status.success == false)
  14. {
  15. $("#loginform").effect("shake", {times:2}, 100);
  16. $("#login_message")
  17. .attr('class', 'ui-state-error')
  18. .html('<strong>ERROR</strong>: Your details were incorrect.<br />');
  19. }
  20. else {
  21. $("#login_message")
  22. .attr('class', 'ui-state-highlight')
  23. .html('<strong>PERFECT</strong>: You may proceed. Good times.<br />');
  24. }
  25. }
  26. });
  27. }
  28. </script>
  29.  
  30. <?php
  31. if (isset($_POST['username'])&& isset($_POST['password']))
  32. {
  33. if (login ($_POST['username'], $_POST['password'])){
  34. $data = array("success" => true);
  35. echo json_encode($data);
  36. }
  37. else {
  38. $data = array("success" => false);
  39. echo json_encode($data);
  40. }
  41. }?>
  42.  
  43. if login = false
  44. {
  45. $data['success'] = false;
  46. echo json_encode($data);
  47. }
  48. else {
  49. $data['success'] = true;
  50. echo json_encode($data);
  51. }
  52.  
  53. if login = false
  54. {
  55. $data['success'] = false;
  56. echo json_encode($data);
  57. }
  58. else {
  59. $data['success'] = true;
  60. echo json_encode($data);
  61. }
  62.  
  63. <?php
  64. if (isset($_POST['username'])&& isset($_POST['password']))
  65. {
  66. if (login ($_POST['username'], $_POST['password'])){
  67. $data = array("success" => true);
  68. echo json_encode($data);
  69. }
  70. else {
  71. $data = array("success" => false);
  72. echo json_encode($data);
  73. }
  74. }?>
Add Comment
Please, Sign In to add comment