Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@page import="java.sql.*" %>
- <%
- String oldPassword = request.getParameter("oldPassword");
- String newPassword1 = request.getParameter("newPassword1");
- Class.forName("com.mysql.jdbc.Driver");
- String url = "jdbc:mysql://localhost:3306/MyWebsite";
- String username = "root";
- String password = "pass";
- Connection con = DriverManager.getConnection(url, username, password);
- Statement st = con.createStatement();
- if (oldPassword.equals(session.getAttribute("Password")))
- {
- String query = "update userInfo set (Password = '"+newPassword1+"') where (Name = '"+session.getAttribute("Username")+"')";
- st.executeUpdate(query);
- session.setAttribute("Password", newPassword1);
- out.println("<script>alert('Your password has been changed. Please login again.')</script>");
- %>
- <script>
- window.location = "index.jsp";
- </script>
- <%
- }
- else
- {
- out.println("<script>alert('There was an error. Try again.')</script>");
- %>
- <script>
- window.location = "MyDetails.jsp";
- </script>
- <%
- }
- %>
Add Comment
Please, Sign In to add comment