📄 changepwd.jsp
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ include file="Connections/myesale.jsp" %>
<%
// *** Edit Operations: declare variables
// set the form action variable
String MM_editAction = request.getRequestURI();
if (request.getQueryString() != null && request.getQueryString().length() > 0) {
String queryString = request.getQueryString();
String tempStr = "";
for (int i=0; i < queryString.length(); i++) {
if (queryString.charAt(i) == '<') tempStr = tempStr + "<";
else if (queryString.charAt(i) == '>') tempStr = tempStr + ">";
else if (queryString.charAt(i) == '"') tempStr = tempStr + """;
else tempStr = tempStr + queryString.charAt(i);
}
MM_editAction += "?" + tempStr;
}
// connection information
String MM_editDriver = null, MM_editConnection = null, MM_editUserName = null, MM_editPassword = null;
// redirect information
String MM_editRedirectUrl = null;
// query string to execute
StringBuffer MM_editQuery = null;
// boolean to abort record edit
boolean MM_abortEdit = false;
// table information
String MM_editTable = null, MM_editColumn = null, MM_recordId = null;
// form field information
String[] MM_fields = null, MM_columns = null;
%>
<%
// *** Update Record: set variables
if (request.getParameter("MM_update") != null &&
request.getParameter("MM_update").toString().equals("form1") &&
request.getParameter("MM_recordId") != null) {
MM_editDriver = MM_myesale_DRIVER;
MM_editConnection = MM_myesale_STRING;
MM_editUserName = MM_myesale_USERNAME;
MM_editPassword = MM_myesale_PASSWORD;
MM_editTable = "customers";
MM_editColumn = "cust_id";
MM_recordId = "" + request.getParameter("MM_recordId") + "";
MM_editRedirectUrl = "account.jsp";
String MM_fieldsStr = "password|value";
String MM_columnsStr = "password|',none,''";
// create the MM_fields and MM_columns arrays
java.util.StringTokenizer tokens = new java.util.StringTokenizer(MM_fieldsStr,"|");
MM_fields = new String[tokens.countTokens()];
for (int i=0; tokens.hasMoreTokens(); i++) MM_fields[i] = tokens.nextToken();
tokens = new java.util.StringTokenizer(MM_columnsStr,"|");
MM_columns = new String[tokens.countTokens()];
for (int i=0; tokens.hasMoreTokens(); i++) MM_columns[i] = tokens.nextToken();
// set the form values
for (int i=0; i+1 < MM_fields.length; i+=2) {
MM_fields[i+1] = ((request.getParameter(MM_fields[i])!=null)?(String)request.getParameter(MM_fields[i]):"");
}
// append the query string to the redirect URL
if (MM_editRedirectUrl.length() != 0 && request.getQueryString() != null) {
MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + request.getQueryString();
}
}
%>
<%
// *** Update Record: construct a sql update statement and execute it
if (request.getParameter("MM_update") != null &&
request.getParameter("MM_recordId") != null) {
// create the update sql statement
MM_editQuery = new StringBuffer("update ").append(MM_editTable).append(" set ");
for (int i=0; i+1 < MM_fields.length; i+=2) {
String formVal = MM_fields[i+1];
String elem;
java.util.StringTokenizer tokens = new java.util.StringTokenizer(MM_columns[i+1],",");
String delim = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:"";
String altVal = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:"";
String emptyVal = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:"";
if (formVal.length() == 0) {
formVal = emptyVal;
} else {
if (altVal.length() != 0) {
formVal = altVal;
} else if (delim.compareTo("'") == 0) { // escape quotes
StringBuffer escQuotes = new StringBuffer(formVal);
for (int j=0; j < escQuotes.length(); j++)
if (escQuotes.charAt(j) == '\'') escQuotes.insert(j++,'\'');
formVal = "'" + escQuotes + "'";
} else {
formVal = delim + formVal + delim;
}
}
MM_editQuery.append((i!=0)?",":"").append(MM_columns[i]).append(" = ").append(formVal);
}
MM_editQuery.append(" where ").append(MM_editColumn).append(" = ").append(MM_recordId);
if (!MM_abortEdit) {
// finish the sql and execute it
Driver MM_driver = (Driver)Class.forName(MM_editDriver).newInstance();
Connection MM_connection = DriverManager.getConnection(MM_editConnection,MM_editUserName,MM_editPassword);
PreparedStatement MM_editStatement = MM_connection.prepareStatement(MM_editQuery.toString());
MM_editStatement.executeUpdate();
MM_connection.close();
// redirect with URL parameters
if (MM_editRedirectUrl.length() != 0) {
response.sendRedirect(response.encodeRedirectURL(MM_editRedirectUrl));
return;
}
}
}
%>
<%
String reccust__MMColParam = "amber";
if (session.getValue("MM_Username") !=null) {reccust__MMColParam = (String)session.getValue("MM_Username");}
%>
<%
Driver Driverreccust = (Driver)Class.forName(MM_myesale_DRIVER).newInstance();
Connection Connreccust = DriverManager.getConnection(MM_myesale_STRING,MM_myesale_USERNAME,MM_myesale_PASSWORD);
PreparedStatement Statementreccust = Connreccust.prepareStatement("SELECT * FROM customers WHERE username = '" + reccust__MMColParam + "'");
ResultSet reccust = Statementreccust.executeQuery();
boolean reccust_isEmpty = !reccust.next();
boolean reccust_hasData = !reccust_isEmpty;
Object reccust_data;
int reccust_numRows = 0;
%>
<%request.setCharacterEncoding("gb2312");%>
<html>
<head>
<title>账户管理-更改密码</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
.style8 {font-size: 24px}
.style6 {color: #009933}
.BOX {
border: 6px solid #339999;
margin-top: 10px;
margin-right: 0px;
margin-bottom: 10px;
margin-left: 0px;
}
.style14 {color: #FFFF00}
.style18 {font-size: 16px}
-->
</style>
</head>
<body>
<div align="center">
<table width="200" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="7"><table width="200" border="3" align="center" cellpadding="2" cellspacing="1" bordercolor="#FFDEC1" class="style6">
<tr>
<td><img src="images/esale_title.jpg" width="760" height="120"></td>
</tr>
</table></td>
</tr>
<tr background="images/life_23.gif">
<td height="20" colspan="7" background="images/line_top.gif"> </td>
</tr>
<tr>
<td width="20" rowspan="3" background="images/line_top.gif"> </td>
<td width="16" rowspan="3" valign="top"> </td>
<td width="50" height="50" align="left" valign="top"><img src="images/border_ul.gif" width="50" height="51"></td>
<td width="586" rowspan="3" align="center"><table width="96%" border="0" align="center" cellpadding="4" cellspacing="0" class="BOX">
<tr bgcolor="#339999">
<td><div align="center" class="style8 style14"><strong> 更改密码 </strong></div></td>
</tr>
<tr>
<td valign="middle"><form ACTION="<%=MM_editAction%>" name="form1" method="POST">
<div align="center">
<p align="left"> </p>
<table width="80%" border="2" align="center" bordercolor="#CCCC66">
<tr>
<td bgcolor="#CCFFCC"><div align="right" class="style8">使用者名称</div></td>
<td><span class="style18"><%=(((reccust_data = reccust.getObject("username"))==null || reccust.wasNull())?"":reccust_data)%></span></td>
</tr>
<tr>
<td height="37" bgcolor="#CCFFCC"><div align="right"><span class="style8">输入新的密码</span></div></td>
<td><input name="password" type="text" id="password" size="20" maxlength="10" /></td>
</tr>
</table>
<input type="submit" name="Submit" value="确定更改">
</div>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="MM_recordId" value="<%=(((reccust_data = reccust.getObject("cust_id"))==null || reccust.wasNull())?"":reccust_data)%>">
</form></td>
</tr>
<tr>
<td align="right" valign="middle"><font color="#000066" size="4"><a href="chart.jsp"></a></font></td>
</tr>
<tr bgcolor="#339999">
<td> </td>
</tr>
</table></td>
<td width="50" height="50" align="right" valign="top"><img src="images/border_ur.gif" width="50" height="51"></td>
<td width="16" rowspan="3"> </td>
<td width="20" rowspan="3" background="images/line_top.gif"> </td>
</tr>
<tr>
<td width="50" height="166"> </td>
<td width="50" height="166"> </td>
</tr>
<tr>
<td width="50" height="50" align="left" valign="bottom"><img src="images/border_dl.gif" width="50" height="51"></td>
<td width="50" height="50" align="right" valign="bottom" background="ima"><img src="images/border_dr.gif" width="50" height="51"></td>
</tr>
<tr>
<td height="20" colspan="7" background="images/line_top.gif"> </td>
</tr>
</table>
<p> </p>
</div>
</body>
</html>
<%
reccust.close();
Statementreccust.close();
Connreccust.close();
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -