<!--#include file=conn.asp-->
<!--#include file=../md5.asp-->
<%if session(hxCacheName&"_admin")<>"OK" then
    response.redirect("admin_login.asp")
    end if
 if request.cookies(hxCacheName&"_rank")("rank")>1 then
  	response.write "<script language='javascript'>"
	response.write "alert('您的级别不够！');"
	response.write "location.href='javascript:history.go(-1)';"			
	response.write "</script>"
    end if%>
<style type="text/css">
<!--
body {
	background-color: #dadae9;
}
body,td,th {
	color: #FF0000;
}
-->
</style>
<%
dim rs,sql,adminname,password,password2,rank
adminname=replace(trim(request("adminname")),"'","‘")
password=replace(trim(request("password")),"'","‘")
password2=replace(trim(request("password2")),"'","‘")
rank=replace(trim(request("rank")),"'","‘")
set rs = Server.CreateObject("ADODB.RecordSet")
sql="select adminname,password,rank from [admin] where adminname='"&adminname&"'" 
rs.open sql,conn,1,3
if not rs.eof or not rs.bof then
response.write "<script language=JavaScript>" & chr(13) & "alert('对不起，该帐号已经存在！');" & "window.location='admin_add.asp'" & "</script>"
response.end
else
if adminname=""  then
	response.write "<script language='javascript'>"
	response.write "alert('出错了，您输入的用户名不能为空！');"
	response.write "location.href='javascript:history.go(-1)';"
	response.write "</script>"
	response.end
	else
if password="" or len(password)<8 or len(password)>16 then
	response.write "<script language='javascript'>"
	response.write "alert('出错了，您输入的密码不能为空！且要求长度为8-16位');"
	response.write "location.href='javascript:history.go(-1)';"
	response.write "</script>"
	response.end
else
if password<>password2 then
	response.write "<script language='javascript'>"
	response.write "alert('出错了，确认密码不相同！');"
	response.write "location.href='javascript:history.go(-1)';"
	response.write "</script>"
	response.end
	else
rs.addnew
rs("adminname")=adminname
rs("password")=md5(password)
rs("rank")=rank
rs.update
end if
end if
end if
end if
rs.close
set rs=nothing

response.write "<script language=JavaScript>" & chr(13) & "alert('恭喜你，添加帐号成功！');" & "window.location='admin_add.asp'" & "</script>"
response.write "<meta http-equiv=refresh content=""1;URL=admin_add.asp"">"
%>