Untitled
unknown
plain_text
2 years ago
3.5 kB
5
Indexable
<%-- Document : index.jsp Created on : Jun 14, 2023, 9:35:44 PM Author : trant --%> <%-- Document : index.jsp Created on : Jun 14, 2023, 9:35:44 PM Author : trant --%> <%@page import="DAOs.AccountDAO"%> <%@page import="Models.Account"%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Login Page</title> <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"> <style> .login-container { display: flex; justify-content: center; align-items: center; height: 100vh; } </style> </head> <body> <div class="login-container"> <div class="card" style="width: 18rem;"> <div class="card-body"> <% if (request.getParameter("btnSubmit") != null && request.getParameter("btnSubmit").equals("Submit")) { String us = request.getParameter("txtUS"); String pwd = request.getParameter("txtPWD"); Account acc = new Account(us, pwd); AccountDAO dao = new AccountDAO(); boolean ketqua = dao.Login(acc); if (ketqua) { // đăng nhập thành công if (request.getParameter("chkRem") != null) { Cookie c = new Cookie("quantri", us); c.setMaxAge(3 * 24 * 60 * 60); // set thời gian của cookie response.addCookie(c); } else { session.setAttribute("quantri", us); } session.setAttribute("fullname", dao.GetFullName(us)); response.sendRedirect("list.jsp"); } else { response.sendRedirect("index.jsp"); } } %> <h5 class="card-title">Login</h5> <form method="post"> <div class="form-group"> <label for="txtUS">Username:</label> <input type="text" class="form-control" id="txtUS" name="txtUS" placeholder="Enter username" required> </div> <div class="form-group"> <label for="txtPWD">Password:</label> <input type="password" class="form-control" id="txtPWD" name="txtPWD" placeholder="Enter password" required> </div> <div class="form-group form-check"> <input type="checkbox" class="form-check-input" id="chkRem" name="chkRem" value="1"> <label class="form-check-label" for="chkRem">Remember me</label> </div> <button type="submit" class="btn btn-primary" name="btnSubmit" value="Submit">Submit</button> </form> </div> </div> </div> <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.3/dist/umd/popper.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script> </body> </html>
Editor is loading...