【JSP开源代码栏目提醒】:本文主要为网学会员提供admin_edit.jsp,希望对需要admin_edit.jsp网友有所帮助,学习一下!
<%@ page language="java" contentType="text/html; charset=GBK" pageEncoding="GB18030" import="java.sql.*,java.util.*,java.io.*"%>
<%@ include file="config.ini"%>
<%@ include file="conn.jsp"%>
<%@ include file="admin_readlogin.jsp"%>
<%@ include file="md5.jsp"%>
<%
//接收请求中提交的动作参数
String action=request.getParameter("action");
if(action==null) {action="";}
//如果请求中提交的参数为save,则执行数据库更新操作
if(action.equals("save"))
{
//接收管理员提交的用户名和密码
String username=codeToString(request.getParameter("username"));
String password=codeToString(request.getParameter("password"));
sqlstr="update [admin] set [username]='"+username+"'";
if(!password.equals(""))
{
password=md5(password);
sqlstr=sqlstr+",[password]='"+password+"'";
}
sqlstr=sqlstr+" where id="+(String)session.getAttribute("iCanadmin");
try
{
//如果管理员用户名和密码都正确,则执行数据库更新操作
iCanDb.doUpdate(sqlstr);
out.print("<script>");
out.print("alert('修改成功!');");
out.print("location.href='admin.jsp';");
out.print("</script>");
}
catch(Exception e)
{
out.print("<script>");
out.print("alert('数据库错误!');");
out.print("location.href='admin.jsp';");
out.print("</script>");
}
}
try
{
//显示更新后的管理员信息
sqlstr="select * from admin where id="+(String)session.getAttribute("iCanadmin");
rs=iCanDb.doSelect(sqlstr);
if(rs.next())
{
String password=rs.getString("password");
String username=rs.getString("username");
%>
<html>
<head>
<%@ include file="head.jsp"%>
</head>
<script language="javascript">
function on_submit()
{//验证数据的合法性
if (form1.password.value != form1.confirmpwd.value)
{
alert("两次输入的密码不一致!");
form1.password.focus();
return false;
}
if (form1.username.value == "")
{
alert("用户名不能为空!");
form1.username.focus();
return false;
}
}
</script>
<body style="text-align: center">
<table border="0" width="760" id="table1" cellspacing="0" cellpadding="0">
<%@ include file="admin_top.jsp"%>
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td colspan="2" height="19"></td>
</tr>
<tr>
<td colspan="2"><center><table border="0" width="500" id="table2" cellspacing="0" cellpadding="0">
<tr>
<td><table border="0" width="100%" id="table2" cellspacing="0" cellpadding="0"><tr>
<td height="25" align="left" valign="middle" background="images/tdbg1.gif">
<table border="0" width="100%" id="table3" cellspacing="0" cellpadding="0">
<tr>
<td>
<p align="center">
<font size="2" color="#FFFFFF"><b>用户资料修改</b></font></td>
</tr>
</table>
</td></tr></table></td>
</tr>
<tr>
<td>
<form method="POST" action="admin_edit.jsp?action=save" style="text-align: center" name="form1" onsubmit="return on_submit()">
<table border="1" width="100%" id="table4" bordercolor="#156FC7" style="border-collapse: collapse" cellpadding="3" cellspacing="0">
<tr>
<td width="20%" height="32">
<p align="center"><font size="2" color="#156FC7"><b>用户名</b></font></td>
<td height="32" width="77%">
<p align="center">
<font color="#156FC7">
<input name="username" size="15" style="border: 1px solid #156FC7" value="<%=username%>"> </font></td>
</tr>
<tr>
<td width="20%" height="32">
<p align="center"><font size="2" color="#156FC7"><b>密
码</b></font></td>
<td height="32" width="77%">
<p align="center">
<font color="#156FC7">
<input name="password" size="15" style="border: 1px solid #156FC7" type="password"><span style="font-size: 9pt; font-weight: 700">(不修改请留空)</span></font></td>
</tr>
<tr>
<td width="20%" height="32">
<p align="center"><font size="2" color="#156FC7"><b>确认密码</b></font></td>
<td height="32" width="77%">
<p align="center">
<font color="#156FC7">
<input name="confirmpwd" size="15" style="border: 1px solid #156FC7" type="password"><span style="font-size: 9pt; font-weight: 700">(不修改请留空)</span></font></td>
</tr>
<tr>
<td colspan="2">
<p align="center">
<input type="submit" value="提交" name="B1" style="border: 1px solid #156FC7">
<input type="button" value="返回" name="B2" style="border: 1px solid #156FC7" onclick="javascript:location.href='admin.jsp';"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td></td>
</tr>
</table></center>
</td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td colspan="2"><%@ include file="copyright.jsp"%></td>
</tr>
</table>
</body>
</html>
<%
}
else
{
out.print("<script>");
out.print("alert('id错误!');");
out.print("location.href='index.jsp';");
out.print("</script>");
}
}
catch(Exception e)
{
out.print("<script>");
out.print("alert('数据库错误!');");
out.print("location.href='index.jsp';");
out.print("</script>");
}
%>
上一篇:
admin_detail.jsp
下一篇:
成本管理详细介绍