图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