Advertisement
Guest User

Untitled

a guest
May 15th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  2. String un = request.getParameter("name");
  3. String pw = request.getParameter("password");
  4.  
  5. // Connect to mysql(mariadb) and verify username password
  6.  
  7. try {
  8. //Class.forName("org.mariadb.jdbc.Driver");
  9. // loads driver
  10. Connection c = DriverManager.getConnection("jdbc:mysql://cs3.calstatela.edu/cs3220stu100","cs3220stu100", "Bc3RmGV*"); // gets a new connection
  11.  
  12. PreparedStatement ps = c.prepareStatement("select name,password from login where name=? and password=?");
  13. ps.setString(1, un);
  14. ps.setString(2, pw);
  15.  
  16. ResultSet rs = ps.executeQuery();
  17.  
  18. while (rs.next()) {
  19. response.sendRedirect("Login_Register.jsp?name=" + un);
  20. return;
  21. }
  22.  
  23. response.sendRedirect("Login_Register.jsp");
  24. return;
  25. } catch (SQLException e) {
  26. e.printStackTrace();
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement