10.23日进度报告

今天做了修改密码的功能

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8" import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>修改密码</title>
</head>
<body>
<jsp:useBean id="db" class="DBBean.Bean" scope="page" />
    <%!String a, b;%>
    <%-- 将ab设为全局变量。 --%>
    <% 
        request.setCharacterEncoding("utf-8");
        String Iname = (String) session.getAttribute("Iname");
        System.out.println(" ");
        System.out.println("resetpass.jsp 界面信息:");
        System.out.println("resetpass界面的Iname:" + Iname);
        String str = "select Iadd,Ifrdb,Iemail,Iyzbm,Iweb,Iclient,Igh,Iphone,Ifax from baseInfo where Iname=" + "'"
                + Iname + "'";
        ResultSet rs2 = db.executeQuery(str);
        
        %>
        <form action="updatepass.jsp" method="post">
        <p>当前登录的用户为: <%=Iname%></p>
        <p>请输入修改后的密码: <input type="password" name="repass1"></p>
        <p>请确认修改后的密码: <input type="password" name="repass2"></p>
        <input type="submit" value="确认修改">
        </form>
    
</body>
<%
        rs2.close();
        db.close();
    %>
</html>
View Code
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="java.sql.*"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<jsp:useBean id="db" class="DBBean.Bean" scope="page" />
<%
 
        request.setCharacterEncoding("utf-8");
        String Iname = (String) session.getAttribute("Iname");
        System.out.println(" ");
        System.out.println("updatepass.jsp 界面信息:");
        System.out.println("updatepass界面的Iname:" + Iname);
        String repassword1 = request.getParameter("repass1");
        String repassword2 = request.getParameter("repass2");
 //判断密码
        System.out.print(repassword1);
        System.out.print(repassword2);
        
        if(repassword1.equals(repassword2))
        {
            Class.forName("com.mysql.jdbc.Driver");
        
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8", "root", "123456");
        Statement stmt = con.createStatement();
        
        String sql = "update baseInfo set Ipassword='" + repassword1 + "' where Iname=" + "'"
        + Iname + "'";

        int i = stmt.executeUpdate(sql);

        if (i == 1) {
            out.println("<h2>修改成功!</h2><br/>");
            
            
        } else {
            out.println("<h2>修改不符合条件,失败!</h2><br/>");
            
        }
        stmt.close();
        con.close();
        }
        else {
            out.println("<h2>修改不符合条件,失败!</h2><br/>");}
%>
</body>

</html>
View Code
原文地址:https://www.cnblogs.com/zhjvvvvvv/p/14206287.html