【JSP开源代码栏目提醒】:网学会员为广大网友收集整理了,admin_del.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"%>
<%
//得到要删除的用户的id
String id=request.getParameter("id");
String action=null;
if(id==null)
{
out.print("<script>");
out.print("alert('用户id错误');");
out.print("location.href='admin.jsp';");
out.print("</script>");
}
%>
<%
try{
//接收请求中包含的参数
action=request.getParameter("action");
//如果请求中包含的参数为del,则执行删除用户操作
if(action.equals("del"))
{
try
{
//从不同的数据表中删除该用户的信息
sqlstr="delete from list where user='"+id+"'";
iCanDb.doDelete(sqlstr);
sqlstr="delete from note1 where user='"+id+"'";
iCanDb.doDelete(sqlstr);
sqlstr="delete from fav where user='"+id+"'";
iCanDb.doDelete(sqlstr);
sqlstr="delete from users where id="+id;
iCanDb.doDelete(sqlstr);
//从储藏箱的目录中删除所有上传的文件
String iCanroot=dirPath.replace('\\','/');
File userBox=new File(iCanroot+"box/"+id);
File userBoxfile[]=userBox.listFiles();
if(userBoxfile.length>0)
{
for(int i=0;i<userBoxfile.length;i++)
{
userBoxfile[i].delete();
}
}
userBox.delete();
out.print("<script>");
out.print("alert('删除成功!');");
out.print("location.href='admin.jsp';");
out.print("</script>");
}
catch(Exception e)
{
out.print("<script>");
out.print("alert("+e+");");
out.print("location.href='admin.jsp';");
out.print("</script>");
}
}
//如果请求中包含的参数为confirm,则执行数据库查询操作
if(action.equals("confirm"))
{
try
{
sqlstr="select username from users where id="+id;
rs=iCanDb.doSelect(sqlstr);
rs.next();
%>
<html>
<head>
<%@ include file="head.jsp"%>
</head>
<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="450" id="table2" cellspacing="0" cellpadding="0">
<tr>
<td><table border="0" width="450" 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">
<b><font size="2" color="#FFFFFF">删除用户</font></b></td>
</tr>
</table>
</td></tr></table></td>
</tr>
<tr>
<td>
<table border="1" width="100%" id="table4" bordercolor="#156FC7" style="border-collapse: collapse" cellpadding="3" cellspacing="0" height="150">
<tr>
<td width="97%" align="center" height="38">
<font size="2" color="#156FC7">确认删除下面的用户?</font></td>
</tr>
<tr>
<td width="97%" height="53">
<p align="center"><font size="2" color="#156FC7"><%=rs.getString("username")%></font></td>
</tr>
<tr>
<td>
<p align="center">
<input type="button" value="提交" name="B1" style="border: 1px solid #156FC7" onclick="javascript:location.href='admin_del.jsp?action=del&id=<%=id%>';">
<input type="button" value="返回" name="B2" style="border: 1px solid #156FC7" onclick="javascript:location.href='admin.jsp';"></td>
</tr>
</table>
</center></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>
<%
}
catch(Exception e)
{
out.print("<script>");
out.print("alert('数据库出错');");
out.print("location.href='note.jsp';");
out.print("</script>");
}
}
else
{
out.print("<script>");
out.print("location.href='admin.jsp';");
out.print("</script>");
}
}
catch(Exception e)
{
out.print("<script>");
out.print("alert("+e+");");
out.print("location.href='admin.jsp';");
out.print("</script>");
}
%>
上一篇:
admin_consul.jsp
下一篇:
扛起年轻化大旗,哈弗F系玩转行业新风潮