Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  
  3. <html>
  4.  
  5. <head>
  6. <meta charset="utf-8">
  7. <link href="style.css" rel="stylesheet">
  8. <title>ИУ4-12Б супер крутой сайт 2000</title>
  9. <script src="http://code.jquery.com/jquery-latest.js"></script>
  10. <script src="jquery.cookie.js"></script>
  11.  
  12. <script>
  13. function formSumbit(register) {
  14. var login = $("#login").val();
  15. var pwd = $("#pwd").val();
  16. if (login == "") { alert("Пустой логин!") }
  17. else if (pwd == "") { alert("Пустой пароль!") }
  18. else {
  19. $('#formResult').html("Загрузка...");
  20. var php = "login.php";
  21. if (register) { php = "register.php" }
  22. $.post(php, {login: login, pwd: pwd},
  23. function(data) { $('#formResult').html(data); })
  24. }
  25. }
  26.  
  27. $(document).ready(function() {
  28. var login = $.cookie('login');
  29. if (login != null) {
  30. $(".loginForm").hide();
  31. $("#showLogin").html(`Вы вошли как ${login}`);
  32. } else {
  33. $(".logined").hide();
  34. }
  35. $("#loginForm").keydown(function(e) {
  36. if (e.which == 13) { formSumbit(false); }});
  37. });
  38. </script>
  39.  
  40. <style>
  41. p.label { margin: 3px auto; }
  42. </style>
  43. </head>
  44.  
  45. <body>
  46. <div class="logined">
  47. <table width="100%"> <tr>
  48. <td id="showLogin"></td>
  49. <td align=right> <input type="button" onclick="$.removeCookie('login'); location = location;" value="Выйти"> </td>
  50. </tr> </table>
  51. </div>
  52. <form id="loginForm" class="loginForm" onsubmit="formSumbit(false)" method="post"> <table>
  53. <tr>
  54. <td> <p class="label">Логин</p> </td> <td> <input type="text" id="login"> </td>
  55. </tr>
  56. <tr>
  57. <td> <p class="label">Пароль</p> </td> <td> <input type="password" id="pwd"> </td>
  58. </tr>
  59. <tr>
  60. <td> <input type="button" onclick="formSumbit(false);" value="Войти"> </td>
  61. <td> <input type="button" onclick="formSumbit(true);" value="Регистрация"> </td>
  62. </tr>
  63. </table> </form>
  64. <div id="formResult" class="loginForm"></div>
  65. </body>
  66.  
  67. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement