📄 admin_profile_action.jsp
字号:
<%@ page language="java" contentType="text/html; charset=GBK"
pageEncoding="GBK"%>
<%@page import="java.util.*,java.io.*,java.sql.*"%>
<%@ include file="../conn.jsp"%>
<!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=GBK">
<title>Insert title here</title>
</head>
<body>
<%
if (null != session.getAttribute("adminlogin")) {
try {
String strDo = "";
String username = "";
String old_password = "";
String new_password = "";
if (null != session.getAttribute("adminlogin"))
username = session.getAttribute("adminlogin")
.toString();
if (null != request.getParameter("old_password"))
old_password = request.getParameter("old_password");
if (null != request.getParameter("password"))
new_password = request.getParameter("password");
//接收空值时跳转到登录页面 防止用户直接访问本页面
if ((username.equals("")) || (old_password.equals(""))) {
response.sendRedirect("../error.jsp");
} else {
//执行查询
strDo = "SELECT * FROM " + tadmin + " WHERE name='"
+ username + "'";
System.out.print(strDo + "\n");
rs = stmt.executeQuery(strDo);
if (rs.next()) {
rs.close();
System.out.print("登录成功\n");
strDo = "UPDATE " + tadmin + " SET";
strDo += " password=SHA('" + new_password
+ "') WHERE name='" + username + "'";
System.out.print(strDo + "\n");
stmt.executeUpdate(strDo);
session.removeAttribute("adminlogin");
response.sendRedirect("admin_login.jsp");
} else {
rs.close();
System.out.print("登录失败\n");
//重定向 登录页
response.sendRedirect("../error.jsp");
}
}
} catch (Exception e) {
e.printStackTrace();
response.sendRedirect("../error.jsp");
} finally {
stmt.close();
conn.close();
}
} else {
response.sendRedirect("../error.jsp");
}
%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -