39 lines
1.5 KiB
Plaintext
39 lines
1.5 KiB
Plaintext
<%@ page language="java" contentType="text/html; charset=GB18030"
|
||
pageEncoding="GB18030" import="java.sql.*"%>
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||
<jsp:useBean id="pass" class="com.DB" scope="page" />
|
||
<jsp:useBean id="times" class="com.Shijian" scope="page" />
|
||
<html>
|
||
<head>
|
||
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
|
||
<title>Insert title here</title>
|
||
</head>
|
||
<body>
|
||
<%
|
||
try {
|
||
String username=new String(request.getParameter("username").getBytes("ISO-8859-1"),"GB18030");
|
||
String password=new String(request.getParameter("password").getBytes("ISO-8859-1"),"GB18030");
|
||
String tel=new String(request.getParameter("tel").getBytes("ISO-8859-1"),"GB18030");
|
||
String jianjie=new String(request.getParameter("jianjie").getBytes("ISO-8859-1"),"GB18030");
|
||
|
||
Connection con=pass.getCon();
|
||
// 添加信息的SQL语句
|
||
String sql = "update reg set password='"+password +"',tel='"+tel +"',jianjie='"+jianjie +"' where username='"+username+"'";
|
||
// 获取PreparedStatement
|
||
PreparedStatement ps = con.prepareStatement(sql);
|
||
// 对SQL语句中的第1个参数赋值
|
||
int row = ps.executeUpdate();
|
||
if(row > 0){
|
||
out.println("<script>alert('更改成功!');window.location.href='ck_up.jsp';</script>");
|
||
}
|
||
// 关闭PreparedStatement,释放资源
|
||
ps.close();
|
||
// 关闭Connection,释放资源
|
||
con.close();
|
||
} catch (Exception e) {
|
||
out.print("更新失败!");
|
||
e.printStackTrace();
|
||
}
|
||
%>
|
||
</body>
|
||
</html> |