📄 admin_news_save.asp
字号:
<!--#include file="config.asp"-->
<!--#include file="conn.asp"-->
<!--#include file="code.asp"-->
<%
'检查管理员是否登录
AdminName = ReplaceBadChar(Trim(Request.Cookies(webkey)("AdminName")))
AdminPassword = ReplaceBadChar(Trim(Request.Cookies(webkey)("AdminPassword")))
RndPassword = ReplaceBadChar(Trim(Request.Cookies(webkey)("RndPassword")))
If AdminName = "" Or AdminPassword = "" Or RndPassword = "" Then
Response.Redirect "Admin_login.asp"
End If
%>
<%
dim rs,options
set rs = server.CreateObject("adodb.recordset")
select case trim(request.form("options"))
case "add"
call add()
case "edit"
call edit()
case "del"
call del()
end select
if trim(request("options"))="del" then
call del()
end if
sub add()
dim title,Content,addtime
title=htmlencode(trim(request.Form("title")))
Content=htmlencode(request.Form("Content"))
addtime=trim(request.Form("addtime"))
if title="" or Content="" then
response.write "<script>alert('标题和内容不能为空,请重新填写');history.back()</script>"
response.end
end if
if addtime="" then
addtime=now()
end if
sql="select * from news where title='"&title&"'"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
rs.close
sql="select * from news"
rs.open sql,conn,1,3
rs.AddNew
rs("title") = title
rs("content") = content
rs("addtime") = addtime
rs("top") = 0
rs("hits") = 0
rs.Update
rs.Close
response.Redirect "Admin_News.asp"
else
rs.close
response.write "<script>alert('当前提交的公告已经存在\n请不要重复提交信息');history.back()</script>"
end if
end sub
sub edit()
set rs = server.CreateObject("adodb.recordset")
dim title,content,id,hits
id=trim(request.form("id"))
if id="" or (not isnumeric(id)) then
response.write "<script>alert('参数不正确!!!');history.back()</script>"
response.end
end if
title=htmlencode(trim(request.Form("title")))
content=htmlencode(request.form("content"))
addtime=request.form("addtime")
Hits=cint(htmlencode(trim(request.form("Hits"))))
if title="" or content="" then
response.write "<script>alert('标题和内容不能为空,请重新填写');history.back()</script>"
response.end
end if
if addtime="" then
addtime=now()
end if
sql="select * from News where id="&id
rs.open sql,conn,1,1
if rs.eof and rs.bof then
rs.close
response.write "<script>alert('数据不存在!');history.back()</script>"
else
rs.close
rs.open sql,conn,1,3
rs("title") = title
rs("content") = content
rs("addtime") = addtime
rs("Hits") = Hits
rs.Update
rs.Close
response.Redirect "Admin_News.asp"
end if
end sub
sub del()
set rs = server.CreateObject("adodb.recordset")
on error resume next
dim id,sql
id=trim(request("id"))
if id="" or (not isnumeric(id)) then
response.write "<script>alert('参数不正确!!!');history.back()</script>"
response.end
end if
sql="delete * from News where id="&id
conn.execute sql
if err.Number<>0 then
err.clear
call closeconn()
response.write "<script>alert('数据库操作失败! ');history.back()"
else
finished
call closeconn()
response.Redirect "Admin_News.asp"
end if
end sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -