?? modify.jsp
字號(hào):
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>無(wú)標(biāo)題文檔</title>
</head>
<body>
<div align="center">修改密碼,密碼長(zhǎng)度不能超過(guò)30個(gè)字符
</div>
<form action="modify.jsp" method="post">
<table width="502" border="0" align="center">
<tr>
<td width="492">輸入你的帳號(hào)</td>
</tr>
<tr>
<td><label>
<input type="text" name="account" />
</label></td>
</tr>
<tr>
<td>輸入你的密碼</td>
</tr>
<tr>
<td><label>
<input type="text" name="pa" />
</label></td>
</tr>
<tr>
<td>輸入你的新密碼</td>
</tr>
<tr>
<td><label>
<input type="text" name="pa1" />
</label></td>
</tr>
<tr>
<td>請(qǐng)?jiān)佥斎胍淮文愕拿艽a</td>
</tr>
<tr>
<td><label>
<input type="text" name="pa2" />
</label></td>
</tr>
<tr>
<td><label>
<input type="submit" name="Submit" value="提交" />
</label></td>
</tr>
</table>
</form>
<%
String account = request.getParameter("account")==null?"":request.getParameter("account");
String password0 = request.getParameter("pa")==null?"":request.getParameter("pa");
String pa1 = request.getParameter("pa1")==null?"":request.getParameter("pa1");
String pa2 = request.getParameter("pa2")==null?"":request.getParameter("pa2");
Connection con = null;
Statement st = null;
ResultSet rs = null;
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
con = DriverManager.getConnection("jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=student", "sa", "");
st = con.createStatement();
String sql = "select password,account from userinfo where account='"+account+"'";
rs = st.executeQuery(sql);
while(rs.next()){
String ac=rs.getString("password");
if(password0.equals(ac)){
if(pa1.equals(pa2)){
st.executeUpdate("update userinfo set password='"+pa1+"'where account='"+account+"'");
out.println("修改成功!");
}
else {out.println("兩次輸入密碼不同!");}
}
else {out.println("輸入密碼不正確!");}
}
} catch (Exception e) {
//out.print("數(shù)據(jù)庫(kù)操作出錯(cuò):" + e);
} finally {
if (rs != null)
rs.close();
if (st != null)
st.close();
if (con != null)
con.close();
}
%>
</body>
</html>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -