请登录后探索更多精彩内容!
修改密码模块:提供修改密码功能。
修改密码页面jsp代码
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <%@ page import="java.sql.*"%> <!DOCTYPE html> <!------------ 修改密码界面 -------------> <html> <head> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE11" /> <title>Insert title here</title> </head> <link rel="stylesheet" type="text/css" href="css/style.css"> <body bgcolor="#d9e1e8"> <div> <table border=0;> <!-- 大标题 --> <caption style="border-bottom:1px solid black;padding:20px;"><h2>修改密码</h2></caption> <!-- 输入框表单 --> <form action="cgpwd_process.jsp" method="post"> <tr><td>原 密 码:<input type="text" name="yuanmima" /></td></tr> <tr><td>新 密 码:<input type="text" name="xinmima"/></td></tr> <tr><td>确认密码:<input type="text" name="cfmima"/></td></tr> <div> <tr><td><input type="reset" value="清空"/> <input type="submit" value="提交" name="rgsubmit"/></td></tr> </div> </form> </table> </div> </body> </html>
修改密码处理过程jsp文件
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <%@ page import="java.sql.*"%> <!DOCTYPE html> <!------------- 修改密码过程 --------------> <html> <head> <title>Insert title here</title> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE11" /> </head> <body> <% String url = "jdbc:mysql://localhost:3306/user?useUnicode=true&characterEncoding=UTF8"; //数据库名 String username = "root"; //数据库用户名 String password = ""; //数据库用户密码 Connection conn = null; //连接状态 Statement stmt = null; ResultSet rs = null; String name = (String)session.getAttribute("u");//接收用户名 String yuanmima = request.getParameter("yuanmima");//原密码 String xinmm = request.getParameter("xinmima");//新密码 String cfmm = request.getParameter("cfmima");//确认密码 Class.forName("com.mysql.jdbc.Driver"); conn=DriverManager.getConnection(url, username, password); stmt = conn.createStatement(); //将新密码和确认密码进行比较 if(xinmm.equals(cfmm)){ stmt.executeUpdate("update userxx set pwd='"+cfmm+"' where pwd='"+yuanmima+"' and name='"+name+"';"); out.println("<script language='javascript'>alert('修改成功!');window.location.href='cgpwd.jsp';</script>"); } else{ out.println("<script language='javascript'>alert('两次密码不一致!');window.location.href='cgpwd.jsp';</script>"); } %> </body> </html>
暂无评论
请先登录后发表评论!
暂无评论