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

📄 adminsave.asp

📁 动网文章3.4修改内容 1. 修正以html方式添加文章表格出错的问题 2. 增加单独打印页面 3. 首页调用1.2版  31. 增加设置是否显示文章专题连接
💻 ASP
字号:
<!--#include file="conn.asp"-->
<%
  	if session("admin")="" then
  		response.redirect "admin.asp"
  	end if
%>
<!--#include file="char.asp"-->
<%
	dim rs,sql
	dim title
	dim content
	dim articleid
	dim classid,Nclassid
	dim Nkey
	dim writer
	dim writefrom
	dim errmsg
	dim founderr
	founderr=false
	if trim(request.form("txttitle"))="" then
  		founderr=true
  		errmsg="<li>文章标题不能为空</li>"
	end if
	if trim(request.form("txtcontent"))="" then
  		founderr=true
  		errmsg=errmsg+"<li>文章内容不能为空</li>"
	end if
	if trim(request.form("key"))="" then
  		founderr=true
  		errmsg=errmsg+"<li>请输入文章关键字</li>"
	end if
	if trim(request.form("classid"))="" then
  		founderr=true
  		errmsg=errmsg+"<li>文章分类不能为空</li>"
	end if
	if trim(request.form("Nclassid"))="" then
  		founderr=true
  		errmsg=errmsg+"<li>文章专题不能为空</li>"
	end if

	if founderr=false then
		title=htmlencode(request.form("txttitle"))
		Nkey=htmlencode(trim(request.form("key")))
		classid=request.form("classid")
		Nclassid=request.form("Nclassid")

		if request("htmlable")="yes" then
		content=htmlencode2(request("txtcontent"))
		else
		content=ubbcode(request.form("txtcontent"))
		end if

	set rs=server.createobject("adodb.recordset")
	if request("action")="add" then
		call newsoft()
	elseif request("action")="edit" then
		call editsoft()
	else
		founderr=true
		errmsg=errmsg+"<li>没有选定参数</li>"
	end if
sub newsoft()
	sql="select * from article where (articleid is null)" 
	rs.open sql,conn,1,3
	rs.addnew
	rs("title")=title
	rs("content")=content
	rs("Nclassid")=Nclassid
	rs("classid")=classid
	rs("Nkey")=Nkey
	rs("hits")=0
	if request.form("writer")<>"" then
		rs("writer")=trim(request.form("writer"))
	end if
	if request.form("writefrom")<>"" then
		rs("writefrom")=trim(request.form("writefrom"))
	end if
	rs("dateandtime")=date()
	rs.update
	articleid=rs("articleid")
end sub
sub editsoft()
	sql="select * from article where articleid="&request("id")
	rs.open sql,conn,1,3
	rs("title")=title
	rs("content")=content
	rs("Nclassid")=Nclassid
	rs("classid")=classid
	rs("Nkey")=Nkey
	if request.form("writer")<>"" then
		rs("writer")=trim(request.form("writer"))
	end if
	if request.form("writefrom")<>"" then
		rs("writefrom")=trim(request.form("writefrom"))
	end if
	rs.update
	articleid=rs("articleid")
end sub

	rs.close
	set rs=nothing
	conn.close
	set conn=nothing
%>
<html>

<head>
<title></title>
<link rel="stylesheet" type="text/css" href="style.css">

</head>

<body>
<div align="center"><center>
<br><br>
<table class="border" align=center width="50%" border="0" cellpadding="4" cellspacing="0" bordercolor="#999999">
  <tr align=center>
    <td width="100%" class="title"  height="20"><b>
<%if request("action")="add" then%>添加<%else%>修改<%end if%>文章成功</b></td>
  </tr>
  <tr>
    <td class="tdbg"><p align="left"><br>
        文章序号为:<%response.write "article"&articleid%><br>
        文章标题为:<%response.write title%></p>
    您可以进行其他操作
    </td>
  </tr>
</table>
</center></div>
<%
else
	Error()
end if
%>

</body>
</html>
<%
sub Error()
	response.write "   <html><head><link rel='stylesheet' href='style.css'></head><body>"
    	response.write "   <br><br><br>"
    	response.write "    <table align='center' width='300' border='0' cellpadding='4' cellspacing='0' class='border'>"
    	response.write "      <tr > "
    	response.write "        <td class='title' colspan='2' height='15'> "
    	response.write "          <div align='center'>由于以下的原因不能保存数据!</div>"
    	response.write "        </td>"
    	response.write "      </tr>"
    	response.write "      <tr> "
    	response.write "        <td align=center class='tdbg' colspan='2' height='23'> "
    	response.write "          <br>"
    	response.write errmsg& " <br><br>"
    	response.write "        <a href='javascript:onclick=history.go(-1)'>返回</a>"        
    	response.write "        <br><br></td>"
    	response.write "      </tr>   </table></body></html>" 
end sub
%>

⌨️ 快捷键说明

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