metalx1000

BASIC Form for Website Login

Oct 16th, 2024
442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.  
  4. <head>
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <style>
  7. @media only screen and (min-width: 600px) {
  8. body {
  9. margin-right: 200px;
  10. margin-left: 200px;
  11. margin-top: 20px;
  12. }
  13. }
  14.  
  15. body {
  16. font-family: Arial, Helvetica, sans-serif;
  17. }
  18.  
  19. form {
  20. border: 3px solid #f1f1f1;
  21. }
  22.  
  23. input[type=text],
  24. input[type=password] {
  25. width: 100%;
  26. padding: 12px 20px;
  27. margin: 8px 0;
  28. display: inline-block;
  29. border: 1px solid #ccc;
  30. box-sizing: border-box;
  31. }
  32.  
  33. button {
  34. background-color: #04AA6D;
  35. color: white;
  36. padding: 14px 20px;
  37. margin: 8px 0;
  38. border: none;
  39. cursor: pointer;
  40. width: 100%;
  41. }
  42.  
  43. button:hover {
  44. opacity: 0.8;
  45. }
  46.  
  47. .cancelbtn {
  48. width: auto;
  49. padding: 10px 18px;
  50. background-color: #f44336;
  51. }
  52.  
  53. .imgcontainer {
  54. text-align: center;
  55. margin: 24px 0 12px 0;
  56. }
  57.  
  58. img.avatar {
  59. width: 40%;
  60. border-radius: 50%;
  61. }
  62.  
  63. .container {
  64. padding: 16px;
  65. }
  66.  
  67. span.psw {
  68. float: right;
  69. padding-top: 16px;
  70. }
  71.  
  72. /* Change styles for span and cancel button on extra small screens */
  73. @media screen and (max-width: 300px) {
  74. span.psw {
  75. display: block;
  76. float: none;
  77. }
  78.  
  79. .cancelbtn {
  80. width: 100%;
  81. }
  82. }
  83. </style>
  84. </head>
  85.  
  86. <body>
  87.  
  88. <h2>Login Form</h2>
  89.  
  90. <form onsubmit="login(event)" action="">
  91. <!-- <div class="imgcontainer"> -->
  92. <!-- <img src="" alt="Avatar" class="avatar"> -->
  93. <!-- </div> -->
  94.  
  95. <div class="container">
  96. <label for="uname"><b>Username</b></label>
  97. <input type="text" placeholder="Enter Username" name="uname" required>
  98.  
  99. <label for="password"><b>Password</b></label>
  100. <input type="password" placeholder="Enter Password" name="password" required>
  101.  
  102. <button type="submit">Login</button>
  103. </form>
  104.  
  105. </body>
  106.  
  107. <script>
  108.  
  109. function login(event){
  110. event.preventDefault();
  111. let name = document.querySelector('input[name="uname"]').value;
  112. let password = document.querySelector('input[name="password"]').value;
  113. let url = window.location.href.replace("https://","");
  114. url = url.split("?")[0];
  115. url = `${name}:${password}@${url}login`;
  116. url = `//${url}`;
  117. console.log(url);
  118. window.location.replace(url);
  119. }
  120.  
  121. </script>
  122. </html>
Advertisement
Add Comment
Please, Sign In to add comment