002

用ASP为一个没有后台功能只有数据库和显示页面的网站编写了后台管理

003主要功能:添加分类 添加文章内容等

代码如下:

if request.QueryString("action")="addclass" then
%>
<form name="form" method="post" action="?action=saveclass">
<table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#F1F1F1" bgcolor="#F5F5F5">
<tr bgcolor="#f1f1f1">
<td height="30" colspan="2">  >>  分类添加</td>
</tr>
<tr>
<td width="12%"><div align="right">分类名称:</div></td>
<td width="88%" height="30">
<input name="v_name" type="text" size="15"> <span style="color: #FF0000">* </span>  <input type="submit" name="Submit2" value=" 添 加 ">
</td>
</tr>
<tr>
<td></td>
<td height="10">

  
</td>
</tr>
</table>
</form>
<%
end if
if request.QueryString("action")="saveclass" then
if request("v_name")="" then
Response.Write "<script Language=Javascript>alert('请全部填写完整!');location.href = 'javascript:history.back()';</script>"
response.end
end if

set rs=server.createobject("adodb.recordset")
rs.open "select * from artBClass",conn,3,2
rs.addnew
rs("BName")=request("v_name")
rs.update
rs.close
Set rs = Nothing

conn.Close
Set conn = Nothing
response.write "<SCRIPT language=JavaScript>alert('添加成功!');"
response.write"this.location.href='?action=classlist';</SCRIPT>"
response.end
end if

if request.QueryString("action")="editclass" then
set rs=server.createobject("adodb.recordset")
sql="SELECT * from artBClass where BID="&(request("id"))&""
rs.open sql,conn,1,1
%>
<form name="form" method="post" action="?id=<%=rs("BID")%>&action=editclasssave">
<table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#F1F1F1" bgcolor="#F5F5F5">
<tr bgcolor="#f1f1f1">
<td height="30" colspan="2">  >>  分类修改</td>
</tr>
<tr>
<td width="12%"><div align="right">分类名称:</div></td>
<td width="88%" height="30">
<input name="v_name" type="text" value="<%=rs("BName")%>" size="15"> <span style="color: #FF0000">* </span>  <input type="submit" name="Submit" value=" 修 改 ">
</td>
</tr>
<tr>
<td></td>
<td height="10">
</td>
</tr>
</table>
</form>
<%
rs.close
Set rs = Nothing
conn.Close
Set conn = Nothing
end if

if request.QueryString("action")="editclasssave" then
if request("v_name")="" then
Response.Write "<script Language=Javascript>alert('请全部填写完整!');location.href = 'javascript:history.back()';</script>"
response.end
end if
set rs=server.createobject("adodb.recordset")
rs.open "select * from artBClass where BID="&(request("id"))&"",conn,2,2
rs("BName")=request("v_name")
rs.update
rs.close
Set rs = Nothing

conn.Close
Set conn = Nothing
response.write "<SCRIPT language=JavaScript>alert('修改成功!');"
response.write"this.location.href='?action=classlist';</SCRIPT>"
response.end
end if

if request.QueryString("action")="addnews" then
%>
<form name="frmadd" id="frmadd" method="post" action="?action=newssave" onSubmit="return CheckForm(this);">
<table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#F1F1F1" bgcolor="#F1F1F1">
<tr bgcolor="#f1f1f1">
<td height="30" colspan="2">   >>  添加新闻</td>
</tr>
<tr bgcolor="#F6F6F6">
<td width="10%" height="36"><div align="right">标 题:</div></td><td width="90%" height="30"> <input name="v_name" type="text" size="60">
  <span style="color: #FF0000">* (必填)</span></td>
</tr>
<tr bgcolor="#F6F6F6">
<td height="40"><div align="right">分 类:</div></td>
<td height="40"> <select name="Nclassid">
<option selected value="">==选择分类==</option>
<%
dim rs11,sql11,sl1
set rs11=server.createobject("adodb.recordset")
sql11="select * from artBClass"
rs11.open sql11,conn,1,1
do while not rs11.eof
sl1="selected"
response.write "<option value='"+CStr(rs11("BID"))+"' name=id>"+rs11("BName")+"</option>"+chr(13)+chr(10)
rs11.movenext
loop
rs11.close
set rs11=nothing
%></select>
 <span style="color: #FF0000">* (请选择文章分类)</span></td>
</tr>
<tr bgcolor="#F6F6F6">
<td valign="top"><div align="right">
<div align="right">内 容:</div>
</div></td>
<td><INPUT type="hidden" name="content"><SCRIPT src="inc/post.js"></SCRIPT></td>
</tr>
<tr bgcolor="#F6F6F6">
<td></td>
<td height="10">

  
</td>
</tr> <tr bgcolor="#F6F6F6">
<td></td>
<td height="10"><input type="submit" value=" 添 加 " name="ok">
 
<input type="reset" value=" 重 置 " name="cancel">
</td>
</tr> <tr bgcolor="#F6F6F6">
<td></td>
<td height="10">

  
</td>
</tr>
</table></form>
<%
end if
if request.QueryString("action")="newssave" then
if request("v_name")="" or request("content")="" or request("Nclassid")="" then
Response.Write "<script Language=Javascript>alert('请全部填写完整!');location.href = 'javascript:history.back()';</script>"
response.end
end if

vdate = now()

set rs=server.createobject("adodb.recordset")
rs.open "select * from artList",conn,3,2
rs.addnew
rs("artTitle")=request("v_name")
rs("artBID")=request("Nclassid")
rs("artSID")="1"
rs("artContent")=request("content")
rs("artTime")=vdate
rs.update
rs.close
Set rs = Nothing
conn.Close
Set conn = Nothing
response.write "<SCRIPT language=JavaScript>alert('添加成功!');"
response.write"this.location.href='?action=list';</SCRIPT>"
response.end
end if

Tags:网站  

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。