Guest User

Untitled

a guest
Jun 29th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. <%@page import="java.sql.*" %>
  2. <%
  3. String oldPassword = request.getParameter("oldPassword");
  4. String newPassword1 = request.getParameter("newPassword1");
  5.  
  6.  
  7. Class.forName("com.mysql.jdbc.Driver");
  8. String url = "jdbc:mysql://localhost:3306/MyWebsite";
  9. String username = "root";
  10. String password = "pass";
  11. Connection con = DriverManager.getConnection(url, username, password);
  12. Statement st = con.createStatement();
  13. if (oldPassword.equals(session.getAttribute("Password")))
  14. {
  15. String query = "update userInfo set (Password = '"+newPassword1+"') where (Name = '"+session.getAttribute("Username")+"')";
  16. st.executeUpdate(query);
  17. session.setAttribute("Password", newPassword1);
  18. out.println("<script>alert('Your password has been changed. Please login again.')</script>");
  19. %>
  20. <script>
  21. window.location = "index.jsp";
  22. </script>
  23. <%
  24. }
  25. else
  26. {
  27. out.println("<script>alert('There was an error. Try again.')</script>");
  28. %>
  29. <script>
  30. window.location = "MyDetails.jsp";
  31. </script>
  32. <%
  33. }
  34.  
  35.  
  36.  
  37.  
  38.  
  39. %>
Add Comment
Please, Sign In to add comment