⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admin_news_act.asp

📁 [FIF]ASP互动视频VIP教程 书包
💻 ASP
字号:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../config/db.asp"-->
<!--#include file="../config/function.inc.asp"-->
<%
dim fs,rst,sql,myErrors
set fs=Server.CreateObject("Scripting.FileSystemObject")
set rst=server.createobject("adodb.recordset")
on error resume next
if request.QueryString("act")="add" or request.QueryString("act")="update" then
%>
<!--#include file="../config/formdata.inc.asp"-->
<%
end if
%>
<html>
<head>
<title>处理新闻</title>
</head>

<body>
<%
'填加新闻,内容,及图片
if request.QueryString("act")="add" then
  sql="tbl_news"
  rst.open sql,conn,1,3
  rst.addnew 
  rst("n_ncid")=formdata.item("upid1")
  rst("n_title")=formdata.item("title")
  rst("n_content")=formdata.item("content")
  rst("n_image")=formdata.item("image")
  rst.update
	rst.close
	set myErrors=conn.errors
	if myErrors.count=0 then
	  msgboxu "添加新闻<" & formdata.item("title") & ">成功!"
	else
	  msgboxU "添加新闻失败!原因:" & myErrors.item(0).description
	  '删除已经上传的文件
	  if formdata.item("image")<>"" then fs.DeleteFile server.MapPath("../upfile") & "\" & formdata.item("image")
	end if
end if
%>


<%
'删除新闻管理
if request.QueryString("act")="del" then
   conn.execute "delete from tbl_news where n_id="&request.QueryString("id")
%>
<%set myErrors=conn.errors
   if myErrors.count=0 then
      msgboxU "删除成功!"
	  if request.QueryString("file")<>"" then fs.DeleteFile server.MapPath("../upfile") & "\" & request.QueryString("file")
   else
      msgboxU "删除失败!原因:"&myErrors.item(0).description
   end if
end if
%>

<%'修改新闻管理
if request.QueryString("act")="update" then
rst.open "select * from tbl_news where n_id=" & request.QueryString("id"),conn,1,3
	  if formdata.item("image1")= "" then '如果原来没有图片,则只修改链接名和地址
		  rst("n_title")=formdata.item("title1")
		  rst("n_content")=formdata.item("content1")
	  else
		  if rst("n_image") <> "" then  '如果原来有图片,则删除图片
		    fs.DeleteFile server.MapPath("../upfile") & "\" & rst("n_image")
		  end if
		  rst("n_image")=formdata.item("image1")
		  rst("n_title")=formdata.item("title1")
		  rst("n_content")=formdata.item("content1")
	  end if
	  rst.update
	rst.close
	set myErrors=conn.errors
	if myErrors.count=0 then
	  msgboxU "修改成功!"
	else
	  msgboxU "修改失败!原因:"&myErrors.item(0).description
  end if
end if
%>

<%'新闻置顶
  if request.QueryString("act")="top" then
     conn.execute "update tbl_news set n_top=true where n_id=" & request.QueryString("id")
	set myErrors=conn.errors
	if myErrors.count=0 then
	  msgboxU "置顶成功!"
	else
	  msgboxU "置顶失败!原因:"&myErrors.item(0).description
  end if
  end if
%>
<%'取消新闻置顶
if request.QueryString("act")="top1" then
     conn.execute "update tbl_news set n_top=false where n_id=" & request.QueryString("id")
	set myErrors=conn.errors
	if myErrors.count=0 then
	  msgboxU "取消置顶成功!"
	else
	  msgboxU "取消置顶失败!原因:"&myErrors.item(0).description
  end if
end if
%>

<%
set rst=nothing
conn.close
set conn=nothing
%>
</body>
</html>

⌨️ 快捷键说明

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