网络开发课程设计Word文档格式.docx
- 文档编号:16192789
- 上传时间:2022-11-21
- 格式:DOCX
- 页数:18
- 大小:315.45KB
网络开发课程设计Word文档格式.docx
《网络开发课程设计Word文档格式.docx》由会员分享,可在线阅读,更多相关《网络开发课程设计Word文档格式.docx(18页珍藏版)》请在冰豆网上搜索。
&
Server.MapPath(database)
conn.Openconnstr
%>
四、创建记录集
Recordset是用来封装一组数据源记录的对象。
Recordset对象在某一时刻只能代表一个记录集合,ADO的核心。
部分记录集创建:
'
从数据库中查询所有记录并按照id降序排列
Setrs=Server.CreateObject("
adodb.Recordset"
)
sql="
select*fromnote_commentorderbyiddesc"
rs.pagesize=msg_per_page
rs.opensql,conn,1,3
从数据库中查询id列的值为id的记录
setrs=server.createobject("
adodb.recordset"
sql="
select*fromnote_commentwhereID="
&
id
rs.opensql,conn,1,3
显示详细资料
setrs=server.createobject("
rs.opensql,conn,1,1
5、课程设计过程
一、数据库设计
Note_admin数据表设计:
Notes_comment数据表设计:
Web数据表设计:
二、留言发布页面设计(book_write.asp)
username=trim(request.form("
username"
))'
读取表单传递过来的姓名数据
usermail=trim(request.form("
usermail"
读取表单传递过来的用户邮箱数据
用户姓名或留言主题或留言内容没有填写
ifusername="
"
orrequest.form("
Comments"
)="
subject"
)="
then
response.write"
script>
alert('
填写资料不完整,请检查后重新输入!
);
history.back();
/script>
response.end
endif
邮箱为必填时检查邮箱是否合法
填写的邮箱地址中不存在字符"
."
或"
@"
,或者邮箱长度小于10或大于50都是非法邮箱地址
ifmailyes=0then
ifInstr(usermail,"
)<
=0orInstr(usermail,"
=0orlen(usermail)<
10orlen(usermail)>
50then
您输入的电子邮件地址格式不正确,请检查后重新输入!
留言主题长度大于要求的长度
iflen(request.form("
))>
subjectmaxlengththen
留言主题太长了,请不要超过"
subjectmaxlength&
个字符!
response.end
endif
留言内容长度大于要求的长度
maxlengththen
response.write"
留言内容太长了,请不要超过"
maxlength&
setrs=Server.CreateObject("
ADODB.RecordSet"
)'
将留言保存到数据库中
rs.Addnew'
添加一条记录
rs("
Name"
)=Request.Form("
)'
姓名
Comment"
comments"
留言内容
Email"
)'
邮箱地址
url"
)'
主页
Communication"
communication"
)'
其他联系方式
IP"
)=Request.serverVariables("
REMOTE_ADDR"
)'
IP地址
PostDate"
)=now()'
留言提交时间
Subject"
)=Request.Form("
留言主题
rs.Update'
更新数据库
rs.close'
关闭RecordSet对象
提交成功,给出提示,并返回到留言查看界面
response.write"
留言提交成功,单击“确定”返回留言列表!
location.href='
index.asp'
;
response.end
三、留言显示页面(index.asp)
<
%
)'
创建RecordSet对象
rs.open"
conn,1,3'
从数据库中读取留言,并保存在rs中
ifrs.eofandrs.bofthen'
不存在留言记录
response.redirect"
book_write.asp"
'
转到撰写留言页面
else'
存在记录
ifcounts=0orcounts="
thencounts=10'
每页留言条数
rs.pageSize=counts'
每页记录数
allpages=rs.pageCount'
总页数
page=Request("
page"
从浏览器取得当前页
IfnotisNumeric(page)thenpage=1'
page不是数字
ifisEmpty(page)orCint(page)<
1then'
page为空或小于1
page=1
elseifCint(page)>
=allPagesthen'
page值大于总页数
page=allPages
endif
rs.AbsolutePage=page'
转到某页头部
DoWhileNotrs.eof
UserName=rs("
用户名
Comments=rs("
内容
Reply=rs("
Reply"
回复
Usermail=rs("
邮件
url=rs("
Url"
主页
replyname=rs("
ReplyName"
回复人姓名
I=I+1'
序号
temp=RS.RecordCount-(page-1)*rs.pageSize-I+1
%>
四、管理员登录页面(admin_login.asp)
ifrequest.QueryString("
act"
login"
then'
管理员登陆
user=Request.Form("
读取从表单传递过来的用户名数据
pass=Request.Form("
password"
读取从表单传递过来的密码数据
SetNArs=Server.CreateObject("
Adodb.RecordSet"
建立RecordSet对象
'
从数据库中查找Admin列的值为user,pwd列的值为pass的记录
sql="
Select*fromnote_adminwhereAdmin='
user&
andpwd='
pass&
执行查询操作,并将结果保存在NArs中
NArs.opensql,conn,1,1
Ifnot(NArs.bofandNArs.eof)Then'
存在满足条件的记录,则登录成功
Session("
ok"
'
将Session变量login置为ok
user"
)=NArs("
Admin"
)'
将当前登录管理员的用户名赋给Session变量user
id"
将当前登录管理员的id赋给Session变量id
Response.Redirect"
admin_main.asp?
action=main"
'
页面转到留言管理界面
Else
Response.Write("
管理员用户名称或密码输入有误,请检查后重新输入!
history.back()<
Response.End
EndIf
NArs.Close'
SetNArs=nothing
EndIf
五、登录失败(admin_loginout.asp)
退出管理,返回留言首页
Session("
'
清除Session变量login中的值
清除Session变量id中的值
清除Session变量user中的值
Response.Redirect("
index.asp"
页面转到留言查看界面
六、登录成功,管理页面(admin_loginmain.asp)
dimrs,msg_per_page
dimsql
msg_per_page=10'
每页显示记录数
Setrs=Server.CreateObject("
ADODB.Recordset"
创建RecordSet对象
rs.pagesize=msg_per_page'
rs.opensql,conn,1,3'
执行查询操作
ifrs.eofandrs.bofthen'
数据库中不存在记录
response.write"
tr>
tdcolspan=6align=center>
BR>
暂时没有留言<
/td>
/tr>
ifnot(rs.eofandrs.bof)then'
检测记录集是否为空
totalrec=RS.RecordCount'
总记录条数
ifrs.recordcountmodmsg_per_page=0then'
计算总页数,recordcount:
数据的总记录数
n=rs.recordcount\msg_per_page'
n:
else
n=rs.recordcount\msg_per_page+1'
endif
currentpage=request("
currentpage:
当前页
Ifcurrentpage<
>
"
then'
currentpage值存在
currentpage=cint(currentpage)'
cint函数将currentpage转换为整数
ifcurrentpage<
1then'
currentpage值小于1
currentpage=1
endif
iferr.number<
0then'
产生某种错误
err.clear'
清除错误信息
endif
else'
currentpage值为空
currentpage=1
Endif
ifcurrentpage*msg_per_page>
totalrecandnot((currentpage-1)*msg_per_page<
totalrec)then
currentPage=1'
当前页大于总页数
endif
rs.absolutepage=currentpage'
absolutepage:
设置指针指向某页开头
rowcount=rs.pagesize'
pagesize:
设置每一页的数据记录数
dimi
dimk
Dowhilenotrs.eofandrowcount>
0'
循环显示所有的记录
content=rs("
subject=rs("
reply=rs("
reply"
回复内容
UserName=rs("
留言者姓名
使用Response对象的write方法在网页上显示复选框、留言者姓名、留言主题、留言内容、留言日期和留言状态
Response.write"
tdalign=center>
inputtype='
checkbox'
value='
rs("
ID"
)&
name=id>
td>
UserName&
Response.writelleft(server.htmlencode(subject),50)
Response.writesubject
建立到管理员回复留言的超级链接
ahref='
action=reply&
id="
Response.writelleft(server.htmlencode(content),50)
Response.writecontent
/a>
Postdate"
ifIsnull(Reply)then'
没有留言回复
response.write"
fontcolor=red>
新留言<
/font>
else'
管理员已经回复留言
已回复"
rowcount=rowcount-1'
显示一条记录后,将每页未显示的记录数减1
rs.movenext'
指向下一条记录
loop
rs.close'
setrs=nothing
%>
endsub
subdelfeedback()'
留言删除
ifdelid="
orisnull(delid)then'
要删除的记录id为空
则给出提示
操作失败,没有选择合适参数,请单击“确定”返回!
admin_main.asp"
'
返回到留言管理界面
id存在
执行数据库中的删除操作,删除数据库中id列的值在delid数组中的记录
conn.Execute("
delete*fromnote_commentwhereIDin("
delid&
)"
删除成功,给出提示
留言删除成功,请单击“确定”返回!
endif
subdetailfeedback()'
留言回复
ifid="
then'
要回复的留言id为空
给出提示
无此留言编号,请单击“确定”返回!
修改留言资料
ifrequest("
send"
then'
提交留言回复内容
id'
rs.opensql,conn,1,3'
执行查询,并将结果保存在rs中
ifnot(rs.eofandrs.bof)t
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 网络 开发 课程设计