Titli Text ^论文标题 20
3. 页面所涉及的数据库表信息
此页面用来显示搜索^论文信息,此页使用了系统中的^论文栏目信息表type。
4. 页面代码分析
‘Html页面表单提交到list.asp
<form action="list.asp" method="post">
‘Html页面显示部分,显示要填写的搜索条件
……
</form>
3.1.8 ^论文信息搜索结果页
1. list.asp页面示例
图3-8为显示^论文信息列表所看到的页面。
3-8 显示^论文信息列表
2. 页面中需要用户填写的Html表单元素
此页无需填写Html表单元素。
3. 页面所涉及的数据库表信息
此页面用来显示^论文信息列表,使用了系统中的^论文信息表main和教师信息表teacher。
3.2 ^论文管理模块
^论文管理模块包含以下子模块。
● 管理员登陆
● ^论文栏目管理
● ^论文信息管理
管理员登陆子模块包含以下页面。
● adminlogin.asp
● asmincheck.asp
● adminmain.asp
^论文栏目管理子模块包含以下页面。
● addtype.asp
● addtypeok.asp
● edittype.asp
● edittypeok.asp
● deltype.asp
● deltypeok.asp
^论文信息管理子模块包含以下页面。
● put.asp
● pubok.asp
● list.asp
● edit.asp
● editok.asp
● admindelcourseware.asp
● admindelcoursewareok.asp
各页面间的关系如图3-9所示。
3-9 各页面间的关系
3.2.1 管理员登陆页
1. adminlogin.asp页面示例
图3-10为管理员登陆所看到的页面。管理员密码为admin。
图3-10 管理员登陆
2. 页面中需要用户填写的Html表单元素
此页共有两个表单元素,如表3所示。
表3 adminlogin.asp页的表单元素
名称 表单元素类型 含义 最大长度
Adminpwd Password 管理员密码 15
3. 页面所涉及的数据库表信息
此页并没有涉及到数据库表的操作。
4. 页面代码分析
‘Html页面表单提交到adminlogin.asp
<form action="admincheck.asp" method="post">
‘Html页面显示部分,显示要填写的登陆信息
……
</form>
3.2.2 验证管理员帐号页
1. 页面中需要用户填写的Html表单元素
此页无需填写Html表单元素。
2. 页面所涉及的数据库表信息
此页面用来验证管理员信息,使用了系统中的管理员表config。
3. 页面代码分析
‘引用创建数据库连接对象函数文件
<!--#include file="conn.asp"-->
<%’取得提交过来的信息
adminpwd = request("adminpwd")
‘如果输入的密码为空
if adminpwd = "" then
conn.close
set conn = nothing
response.write "<script>alert('请输入密码');history.go(-1);</script>"
response.end
end if
sql = "select * from config"
set rs = server.createobject("adodb.recordset")
rs.open sql,conn,1,1
‘如果输入的密码与数据库中密码一致说明密码正确,登陆成功
if adminpwd = rs("adminpwd") then
‘登陆成功后 session("admin")起用
session("admin")=”admin”
rs.close
set rs = nothing
conn.close
set conn = nothing
‘登陆成功后就跳转到管理页面
response.redirect "adminmain.asp"
‘如果输入的密码与数据库中密码不一致说明密码输入错误
else
rs.close
set rs = nothing
conn.close
set conn = nothing
response.write "<script>alert('密码错误');window.location.href='adminlogin.asp';</script>"
3.2.3 管理员登陆成功页
1.adminmain.asp页面示例
图3-11为管理员登陆成功后所看到的页面。
图3-11 管理员登陆成功
2. 页面中需要用户填写的Html表单元素
此页无需填写Html表单元素。
3. 页面所涉及的数据库表信息
此页使用了系统中的管理员表config。
4. 页面代码分析
‘引用创建数据库连接对象函数文件
<!--#include file="conn.asp"-->
‘引用判断是否是管理员登陆文件
<!--#include file="isadmin.asp"-->
‘Html页面显示部分
……
<frameset rows="*" cols="100,*,0" framespacing="0" frameborder="NO" border="0">
<frame src="adminleft.asp" name="left" scrolling="NO" noresize>
<frame src="adminindex.asp" name="main" noresize>
3.2.4 增加^论文栏目页
1. addtype.asp页面示例
图3-12为增加栏目信息所看到的页面。
2. 页面中需要用户填写的Html表单元素
此页仅有1个表单元素,如表4所示。
表4 addtype.asp页的表单元素
名称 表单元素类型 含义 最大长度
Addtype Text 栏目名称 10
3. 页面所涉及的数据库表信息
此页面用来增加栏目信息,使用了系统中的栏目信息记录表type。
4. 页面代码分析
<%’取得栏目信息
sql = "select * from type"
set rs = server.createobject("adodb.recordset")
‘打开记录集对象
rs.open sql,conn,1,1
‘显示栏目信息
do while not rs.eof
response.write "<tr align='center'><td width=180>"&rs("type")&"</td>"
response.write "<td><a href=edittype.asp?id="&rs("typeid")&">编辑</a>/<a href=deltype.asp?id="&rs("typeid")&">删除</a></td></tr>"
‘取下一条栏目信息
rs.movenext
loop
‘关闭记录集对象
rs.close
set rs = nothing
‘关闭数据库连接对象
conn.close
set conn = nothing
%>
‘Html页面表单提交到addtype.doc
<form action="addtypeok.asp" method="post">
请输入要添加的栏目名称:<input type=text name="addtype" size=10><input type=submit name="submit" value="添加">
<br>(栏目名称可以如“论文”、“实验素材”等)
</form>
3.2.5 增加栏目成功页
1. 页面中需要用户填写的Html表单元素
此页无需填写Html表单元素。
2. 页面所涉及的数据库表信息
此页使用了系统中的栏目信息记录表type。
3. 页面代码分析
‘引用创建数据库连接对象函数文件
<!--#include file="conn.asp"-->
‘引用判断是否是管理员登陆文件
<!--#include file="isadmin.asp"-->
<%’取得输入的栏目名称
addtype = trim(request("addtype"))
if addtype = "" then
response.write "<script>alert('请输入要添加的栏目名');history.go(-1);</script>"
conn.close
set conn = nothing
response.end
end if
if len(addtype) > 5 then
response.write "<script>alert('栏目名不得超过5个汉字');history.go(-1);</script>"
conn.close
set conn = nothing
response.end
end if
‘查找栏目信息表是否有栏目名相同的记录
sql = "select * from type where type='"&addtype&"'"
set rs = server.createobject("adodb.recordset")
rs.open sql,conn,1,3
‘如果有则提示
if not (rs.bof and rs.eof) then
rs.close
set rs = nothing
conn.close
set conn = nothing
response.write "<script>alert('数据库中已经有一个名为"&addtype&"的栏目了');history.go(-1);</script>"
response.end
else
‘如果没有记录则可以添加了
rs.addnew
rs("type")=addtype
rs.update
‘关闭记录集对象
rs.close
set rs = nothing
‘关闭数据库连接对象
conn.close
set conn = nothing
end if
response.write "<script>alert('添加成功');window.location.href='addtype.asp';</script>"
%>
3.2.6 修改栏目信息页
1. edittype.asp页面示例
图3-13为修改栏目信息所看到的页面。
图3-13 修改栏目信息
2. 页面中需要用户填写的Html表单元素
此页仅有1个表单元素,如表5所示。
表5 edittype.asp页的表单元素
名称 表单元素类型 含义 最大长度
Addtype Text 栏目名称 10
3. 页面所涉及的数据库表信息
此页用来修改栏目信息页面,使用了系统中的栏目信息记录表type。
4. 页面代码分析
‘引用创建数据库连接对象函数文件
<!--#include file="conn.asp"-->
‘引用判断是否是管理员登陆文件
<!--#include file="isadmin.asp"-->
<%’取得要修改栏目信息的id号
id = trim(request("id"))
sql = "select * from type where typeid="&id
set rs = server.createobject("adodb.recordset")
‘打开栏目信息表查找需要修改的栏目名称
rs.open sql,conn,1,1
filetype = rs("type")
‘关闭记录集对象
rs.close
set rs = nothing
‘关闭数据库连接对象
conn.close
set conn = nothing
%>
‘Html页面显示部分
……
‘Html页面表单提交到edittypeok.asp
<form action="edittypeok.asp" method="post">
将栏目“<%=filetype%>”更名为:<input type=text name="addtype" size=10 value="<%=filetype%>">
<input type=hidden name="id" value="<%=id%>">
<input type=submit name="submit" value="修改">
<br>(栏目名称可以如“论文”、“实验素材”等)
</form>
3.2.7 保存修改的栏目信息页
1. 页面中需要用户填写的Html表单元素
此页无需填写Html表单元素。
2. 页面所涉及的数据库表信息
此页使用了系统中的栏目信息记录表type。
3. 页面代码分析
‘引用创建数据库连接对象函数文件
<!--#include file="conn.asp"-->
‘引用判断是否是管理员登陆文件
<!--#include file="isadmin.asp"-->
<%’取得要修改的栏目信息的id号
id = trim(request("id"))
addtype = trim(request("addtype"))
‘如果没有输入栏目名称则提示
if addtype = "" then
response.write "<script>alert('请输入栏目名');history.go(-1);</script>"
conn.close
set conn = nothing
response.end
end if
‘栏目名称的长度不能大于5
if len(addtype) > 5 then
response.write "<script>alert('栏目名不得超过5个汉字');history.go(-1);</script>"
conn.close
set conn = nothing
response.end
end if
‘打开栏目信息表查找需要修改的栏目名称
sql = "select * from type where type='"&addtype&"' and typeid<>"&id
set rs = server.createobject("adodb.recordset")
rs.open sql,conn,1,1
‘如果修改的名称在数据库中已经有记录则不能修改
if not (rs.bof and rs.eof) then
rs.close
set rs = nothing
conn.close
set conn = nothing
response.write "<script>alert('数据库中已经有一个名为"&addtype&"的栏目了');history.go(-1);</script>"
response.end
end if
rs.close
set rs = nothing
‘如果修改的名称在数据库中没有记录了则可以修改
conn.execute "update type set type='"&addtype&"' where typeid="&id
conn.close
set conn = nothing
response.write "<script>alert('修改成功');window.location.href='addtype.asp';</script>"
%>
3.2.8 删除栏目信息页
1. deltype.asp页面示例
图3-14为删除栏目信息所看到的页面。
图3-14 删除栏目信息
2. 页面中需要用户填写的Html表单元素
此页无需填写Html表单元素。
3. 页面所涉及的数据库表信息
此页使用了系统中的栏目信息记录表type。
4. 页面代码分析
‘Html页面表单提交到deltypeok.asp
<form action="deltypeok.asp" method="post">
<table style="BORDER-COLLAPSE: collapse" borderColor=#808080 width="250" border="1" align="center" cellpadding=1>
<tr><td align="center" class="header">将有下列数据被删除</td></tr>
<tr><td align="left">
1.该栏目在数据库中的记录<br>
2.所有属于该栏目的^论文
</td></tr>
</table>
<center><input type=hidden name="id" value="<%=id%>"><br>
<input type=submit name="submit" value="确定"> <input type=button name="cancle" value="取消" onclick="history.go(-1);"></center>
</form>
3.2.9 删除栏目信息成功页
1. 页面中需要用户填写的Html表单元素
此页无需填写Html表单元素。
2. 页面所涉及的数据库表信息
此页使用了系统中的栏目信息记录表type。
3. 页面代码分析
‘引用创建数据库连接对象函数文件
<!--#include file="conn.asp"-->
‘引用判断是否是管理员登陆文件
<!--#include file="isadmin.asp"-->
<%’取得要删除栏目信息的id号
id = trim(request("id"))
‘如果要删除栏目信息的id号为空说明非法操作
if id = "" then
conn.close
set conn = nothing
response.write "<script>alert('请不要捣乱');top.window.location.href='adminmain.asp';</script>"
response.end
end if
‘查找对应id号的栏目信息
sql = "select * from type where typeid="&id
set rs = server.createobject("adodb.recordset")
‘打开记录集对象
rs.open sql,conn,1,1
‘对应id号的栏目信息如果不存在则说明该栏目不存在
if rs.bof and rs.eof then
rs.close
set rs = nothing
conn.close
set conn = nothing
response.write "<script>alert('请不要捣乱');top.window.location.href='adminmain.asp';</script>"
response.end
end if
rs.close
set rs = nothing
‘对应id号的栏目信息如果存在则删除栏目信息
conn.execute "delete from type where typeid="&id
‘删除^论文信息中对应栏目id号的^论文信息
conn.execute "delete from main where idoftype="&id
‘关闭数据库连接对象
conn.close
set conn = nothing
response.write "<script>alert('删除成功');window.location.href='addtype.asp';</script>"
%>
3.2.10 发布^论文信息页
1.pub.asp页面示例
图3-15为发布^论文信息所看到的页面。
2. 页面中需要用户填写的Html表单元素
此页共有6个表单元素,如表6所示。
表6 pub.asp页的表单元素
名称 表单元素类型 含义 最大长度
Teacher Text 教师姓名 15
Course Text 课程名称 15
Title Text ^论文标题 52
Fileurl Text ^论文地址 52
Filesize Text ^论文大小 15
content textarea ^论文简介 300
3. 页面所涉及的数据库表信息
此页用来发布^论文信息页面,使用了系统中的栏目信息记录表type。
4. 页面代码分析
‘Html页面表单提交到pubok.asp
<form action="pubok.asp" method="post" onSubmit=submitonce(this)>
‘Html页面显示部分,填写^论文信息
……
<%’取得栏目信息
sql = "select * from type"
set rs = server.createobject("adodb.recordset")
rs.open sql,conn,1,1
%>
<select name="type">
<option value="" selected>请选择</option>
<%’显示栏目信息
do while not rs.eof
%>
<option value="<%=rs("typeid")%>"><%=rs("type")%></option>
<%’取下一条栏目信息
rs.movenext
loop
response.write "</select>"
‘关闭记录集对象
rs.close
set rs = nothing
%>
3.2.11 ^论文信息发布成功页
1. 页面中需要用户填写的Html表单元素
此页无需填写Html表单元素。
2. 页面所涉及的数据库表信息
此页使用了系统中的^论文信息记录表main。
3.2.12 ^论文信息列表页
图3-16为^论文信息列表页面。
2. 页面中需要用户填写的Html表单元素
此页无需填写Html表单元素。
3. 页面所涉及的数据库表信息
此页面用来显示^论文信息列表,使用了系统中的^论文信息表main和教师信息表teacher。
4. 页面代码分析
代码与3.2.8节的删除栏目信息页基本相同。
3.2.13 ^论文信息修改页
1. edit.asp页面示例
图3-17为修改^论文信息所看到的页面。
图3-17 修改^论文信息
2. 页面中需要用户填写的Html表单元素
此页共有5个表单元素,如表7所示。
表7 edit.asp页的表单元素
名称 表单元素类型 含义 最大长度
Course Text 课题名称 15
Title Text ^论文标题 52
Fileurl Text ^论文地址 52
Filesize Text ^论文大小 15
Content Textarea ^论文简介 300
3. 页面所涉及的数据库表信息
此页用来修改^论文信息,使用了系统中的^论文信息记录表main。
4. 页面代码分析
‘引用创建数据库连接对象函数文件
<!--#include file="conn.asp"-->
‘引用判断是否是教师登陆文件
<!--#include file="isteacher.asp"-->
‘引用网站设置文件
<!--#include file="fenlei.asp"-->
<%’取得要修改^论文信息的id号
id = request("id")
‘必须输入要修改^论文信息的id号
if id = "" then
conn.close
set conn = nothing
response.write "<script>alert('请不要捣乱');top.window.location.href='teachermain.asp';</script>"
response.end
end if
‘取得要显示的^论文信息
sql = "select * from main,teacher where main.idofteacher=teacher.teacherid and main.mainid="&id
set rs = server.createobject("adodb.recordset")
rs.open sql,conn,1,1
‘如果信息不存在则不能修改
if rs.bof and rs.eof then
rs.close
set rs = nothing
conn.close
set conn = nothing
response.write "<script>alert('请不要捣乱');top.window.location.href='teachermain.asp';</script>"
response.end
else
‘如果存在判断用户是否有修改^论文的权限
if rs("teacherid") <> int(session("teacherid")) and session("admin") <> "admin" then
rs.close
set rs = nothing
conn.close
set conn = nothing
response.write "<script>alert('这个^论文不是你发布的,你想干什么?');top.window.location.href='teachermain.asp';</script>"
&nb