admin_adminsave.asp

来自「一个美化的论坛程序」· ASP 代码 · 共 75 行

ASP
75
字号
<!--#include file="conn.asp"-->
<!--#include file="const.asp"-->
<!--#include file="function.asp"-->
<%
CheckAdmin
dim founderr,errmsg
founderr=false
set rs=server.CreateObject("ADODB.RecordSet")
action=request("action")
adminid=request("adminid")
if action="del" then
	sql="select * from admin"
	rs.open sql,conn,1,1
	if rs.eof or rs.recordcount<=1 then
		errmsg="<li>至少要保留一位管理员!"
		call error()
	else
		conn.execute "delete * from admin where adminid="&adminid
		response.redirect "admin_admin.asp"
	end if
	rs.close
	response.end
end if
if trim(request.form("admin"))="" then
	errmsg="<li>用户名不能为空!"
	call error()
	response.end
else
	admin=trim(request.form("admin"))
end if
if trim(request.form("password"))="" then
	errmsg="<li>密码不能为空!"
	call error()
	response.end
else
	password=trim(request.form("password"))
end if
if action="add" then
	call add()
elseif action="edit" then
	call edit()
else
	errmsg="<li>参数错误"
	founderr=true
	response.end
end if
if founderr=true then
	call error()
	response.end
end if
response.redirect "admin_admin.asp"
sub add()
sql="select * from admin"
rs.open sql,conn,1,3
	rs.addnew 
	rs("admin")=admin
	rs("password")=password
	rs.update
rs.close
end sub
sub edit()
sql="select * from admin where adminid="&adminid
rs.open sql,conn,1,3
if rs.eof then
	rs.close
	errmsg="<li>没有找到该管理员,数据库更新失败!"
	founderr=true
else
	rs("admin")=admin
	rs("password")=password
	rs.update
end if
rs.close
end sub
%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?