Guest User

Untitled

a guest
Jul 7th, 2018
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. //LOGIN & LOGOUT
  2. function login(input) {
  3. if (document.getElementById("menuloginlogout").value == "") {
  4. return false;
  5. }
  6.  
  7. if (window.XMLHttpRequest) {
  8. var xhr = new XMLHttpRequest();
  9. }
  10. else {
  11. var xhr = new ActiveXObject("Microsoft.XMLHTTP");
  12. }
  13.  
  14. xhr.onreadystatechange = function() {
  15. if (xhr.readyState == 4) {
  16. var login = xhr.responseText;
  17. document.getElementById("menuloginlogout").innerHTML = login;
  18. }
  19. else {
  20. document.getElementById("menuloginlogout").innerHTML ='<img src="js/ajax-loader.gif"/>';
  21. }
  22. }
  23.  
  24. var username=encodeURIComponent(document.getElementById("username").value)
  25. var password=encodeURIComponent(document.getElementById("password").value)
  26. var parameters="username="+username+"&password="+password
  27.  
  28. xhr.open("POST", "login.php", true)
  29. xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
  30. xhr.send(parameters)
  31.  
  32. document.getElementById("menuloginlogout").style.display='block';
  33. }
  34.  
  35. function logout(input) {
  36. if (document.getElementById("menuloginlogout").value == "") {
  37. return false;
  38. }
  39.  
  40. if (window.XMLHttpRequest) {
  41. var xhr = new XMLHttpRequest();
  42. }
  43. else {
  44. var xhr = new ActiveXObject("Microsoft.XMLHTTP");
  45. }
  46.  
  47. xhr.onreadystatechange = function() {
  48. if (xhr.readyState == 4) {
  49. var logout = xhr.responseText;
  50. document.getElementById("menuloginlogout").innerHTML = logout;
  51. }
  52. else {
  53. document.getElementById("menuloginlogout").innerHTML ='<img src="js/ajax-loader.gif"/>';
  54. }
  55. }
  56.  
  57. xhr.open("GET", "logout.php");
  58. xhr.send(null);
  59.  
  60. document.getElementById("menuloginlogout").style.display='block';
  61. }
Add Comment
Please, Sign In to add comment