Advertisement
Guest User

Untitled

a guest
Feb 17th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 2.04 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <title>Aufgabe 2</title>
  5.         <meta charset="utf-8">
  6.         <link type="text/css" rel="stylesheet" href="index.css">
  7.  
  8.         <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css">
  9.     </head>
  10.     <body>
  11.         <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js" type="text/javascript"></script>
  12.         <script src="http://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.0.2/js/toastr.min.js" type="text/javascript"></script>
  13.  
  14.         <div style="display: flex; justify-content: center;">
  15.             <img src="header.jpg" alt="Header Image" align="middle" id="header">
  16.         </div><br>
  17.  
  18.         <div align="center" id="content">
  19.             Username: <input type="text" id="username" name="username" placeholder="Username" required><br><br>
  20.             Password: <input type="password" id="password" name="password" placeholder="Password" required><br><br>
  21.             <button style="width: 100px; height: 50px;" type="submit" name='login' onclick="login()">Login</button>
  22.         </div>
  23.  
  24.     </body>
  25. </html>
  26.  
  27. <script>
  28.  
  29.     function login()
  30.     {
  31.         var username = $('#username').val();
  32.         var password = $('#password').val();
  33.  
  34.         $('#username').val("");
  35.         $('#password').val("");
  36.  
  37.         if(username.match("^[a-zA-Z]+$") && password.match("^[a-zA-Z0-9 ]+$"))
  38.        {
  39.            $.post("handler.php",
  40.                {
  41.                    username: username,
  42.                    password: password
  43.                },
  44.                function(data, status){
  45.                    if(data == "true")
  46.                    {
  47.                        location = "employees_list.html";
  48.                     }
  49.                     else
  50.                     {
  51.                         toastr.warning("username or password wrong");
  52.                     }
  53.                 });
  54.         }
  55.         else
  56.         {
  57.             toastr.warning("Check your username and password syntax");
  58.         }
  59.     }
  60. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement