Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- String un = request.getParameter("name");
- String pw = request.getParameter("password");
- // Connect to mysql(mariadb) and verify username password
- try {
- //Class.forName("org.mariadb.jdbc.Driver");
- // loads driver
- Connection c = DriverManager.getConnection("jdbc:mysql://cs3.calstatela.edu/cs3220stu100","cs3220stu100", "Bc3RmGV*"); // gets a new connection
- PreparedStatement ps = c.prepareStatement("select name,password from login where name=? and password=?");
- ps.setString(1, un);
- ps.setString(2, pw);
- ResultSet rs = ps.executeQuery();
- while (rs.next()) {
- response.sendRedirect("Login_Register.jsp?name=" + un);
- return;
- }
- response.sendRedirect("Login_Register.jsp");
- return;
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement