<!--#include file="conn.asp"-->
<%
if session("admin")="" then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('请先登录！');location.href='index.asp' ;</script>"
response.End
else
if request.cookies("sundxshop")("admin")="" then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('请先登录！');location.href='index.asp' ;</script>"
response.End
end if
end if
if session("rank")>1 then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('你无权设置管理员权限！');history.go(-1);</script>"
response.End
end if
%>
<!--#include file="../func.asp"-->
<%dim action,admin,id
action=FormatSQL(SafeRequest("action",0))
id=SafeRequest("id",1)
admin=trim(request.form("admin"))
select case action

case "edit"
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from admin where id="&id,conn,1,3
rs("admin")=admin
if trim(request.form("UserPassword"))<>"" then
rs("UserPassword")=md5(trim(request.form("UserPassword")))
end if
rs("rank")=int(request.form("rank"))
rs.Update
rs.Close
set rs=nothing
response.Write "<script language=javascript>alert('修改成功！');history.go(-1);</script>"
response.End

case "add"
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from admin",conn,1,3
rs.addnew
rs("admin")=trim(request.form("admin2"))
rs("UserPassword")=md5(trim(request.form("UserPassword2")))
rs("rank")=int(request.form("rank2"))
rs.update
rs.close
set rs=nothing
response.Write "<script language=javascript>alert('添加成功！');history.go(-1);</script>"
response.End

case "del"
conn.execute ("delete from admin where id="&id)
response.Redirect "master.asp"
end select
%>
