当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

SQL Server 2000 实用教程_15.3.3 留言簿

资源类别:文库,文档格式:DOC,文档页数:24,文件大小:336KB,团购合买
点击下载完整版文档(DOC)

電子工業出版社 JEUISHING HOUSE DF ELECTRONCS INDSTR 15.3.3留言簿 留言簿可供用户留言、发布信息。留言簿的使用对象可分为一般用户及留言簿管理员两 类,一般用户只能浏览及留言,管理员除了可以浏览及留言之外还可以删除、修改留言。以 下将逐一介绍浏览、留言、管理员登陆验证、删除及修改留言5个功能。 留言簿数据库名为:Demo,它包括的数据库表有 guestbook_ admins(如表152所示) guestbook users(如表153所示)及 guestbook messages(如表154所示)。表 guestbook admin 及 guestbook_ users是管理员及用户的信息表,表 guest messages是留言信息表。数据库表 结构如下: 表152 guestbook admins表结构 列名数据类型长度允许空 username Chat Password Char 20 表15.3 guestbook users表结构 列 据类型 Password Char 20 表154 guestbook 列名 数据类型长度 bigint Username Char Subject Char 100 Content Char 1000 浏览 以下是浏览留言的界面。用户必须先在图1522的窗口中选择要浏览的留言,然后进入 图1523的窗口,进行浏览。可以看出图1522、图15.23与【例15.9】类似,所以可以 引用【例15.9】的程序“ sele record.asp”与“ list sele record.asp”实现浏览的功能

15.3.3 留言簿 留言簿可供用户留言、发布信息。留言簿的使用对象可分为一般用户及留言簿管理员两 类,一般用户只能浏览及留言,管理员除了可以浏览及留言之外还可以删除、修改留言。以 下将逐一介绍浏览、留言、管理员登陆验证、删除及修改留言 5 个功能。 留言簿数据库名为:Demo,它包括的数据库表有 guestbook_admins(如表 15.2 所示), guestbook_users(如表 15.3 所示)及 guestbook_messages(如表 15.4 所示)。表 guestbook_admin 及 guestbook_users 是管理员及用户的信息表,表 guest_messages 是留言信息表。数据库表 结构如下: 表 15.2 guestbook_admins 表结构 列名 数据类型 长度 允许空 username Char 20 √ Password Char 20 √ 表 15.3 guestbook_users 表结构 列名 数据类型 长度 允许空 Username Char 20 √ Password Char 20 √ 表 15.4 guestbook_massages 表结构 1.浏览 以下是浏览留言的界面。用户必须先在图 15.22 的窗口中选择要浏览的留言,然后进入 图 15.23 的窗口,进行浏览。可以看出 图 15.22 、图 15.23 与【例 15.9】类似,所以可以 引用【例 15.9】的程序“sele_record.asp”与“list_sele_record.asp”实现浏览的功能。 列名 数据类型 长度 允许空 Id bigint 8 Username Char 20 √ Subject Char 100 √ Content Char 1000 √ [Date] datetime 8 √

電子工業出版社 JEUISHING HOUSE DF ELECTRONCS INDSTR 口功藏攻言 地址如同]C功度印 留言板 直页言置理 发言主题 发 发言时问 2004-0-】11747:39 204-5-31t8:5851 德本地 奥开为2叫|黑想功国ta 图15.22选择要浏览的留言 留言板 百直置 日期:2004-5-31 图15.23 言内 实 谷 建立一个到数据源的连接 strDSN="ProviderMSDASQL DRIVER=SQL Serveri: SERVER=127.0.0.1: DATABASE=Demo UID=chen; PWD=123 Set connDemo= Server CreateObject("ADODB Connection") connDemo. Open: 建立记录集,存放查询结果 Dim rsMessages Dim strsqlselectMessages

图 15.22 选择要浏览的留言 图 15.23 显示留言内容 <% '建立一个到数据源的连接 Dim strDSN Dim connDemo strDSN="Provider=MSDASQL;DRIVER={SQL Server};SERVER=127.0.0.1;DATABASE=Demo;UID=chen;PWD=123" Set connDemo = Server.CreateObject("ADODB.Connection") connDemo.Open strDSN '建立记录集,存放查询结果 Dim rsMessages Dim strSqlSelectMessages

電子工業出版社 JEUISHING HOUSE DF ELECTRONCS INDSTR Set rsMessages=Server CreateObject("ADODB. Recordset") strSqlselectMessages="SELECT" FROM guestbook messages ORDER BY date ISelectMessages, connDemo, 3, 3 function Open newwinwindow. open(url,"blank","toolbar=no, location=no, directories=no, status=no,"+ menubarno, scrollbars=yes, resizable-yes, " top=50, left=120, width=600, height=400") return false table width=550"height=18> 留言板 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp, &nbsp; &nbsp:; &nbsp: &nbsp &nbsp &nbs ef="select record gue. asp"> 首页&nbsp,&nbsp,留言 a>&nbsp; &nbsp; " logon. asp">管理 If Not rsMessages Eof Then

Set rsMessages = Server.CreateObject("ADODB.Recordset") strSqlSelectMessages="SELECT * FROM guestbook_messages ORDER BY date" rsMessages.Open strSqlSelectMessages, connDemo,3,3 %> 功能模块“留言板” function OpenWindows(url){ var newwin=window.open(url,"_blank","toolbar=no,location=no,directories=no,status=no,"+ "menubar=no,scrollbars=yes,resizable=yes,"+ "top=50,left=120,width=600,height=400"); return false; } 留言板 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ; 首页&nbsp;&nbsp; 留言 &nbsp;&nbsp; 管理 <% If Not rsMessages.Eof Then

電子工業出版社 JEUISHING HOUSE DF ELECTRONCS INDSTR 发言主题 发言者 发言时间 onClick=return Open Windows( this href) > 接受表单输入的数据 建立一个到数据源的连接 Dim strdsN

%> 发言主题 发言者 发言时间 " onClick='return OpenWindows(this.href);'> <% '接受表单输入的数据 Dim id id=Request.QueryString("id") '建立一个到数据源的连接 Dim strDSN Dim connDemo

電子工業出版社 JEUISHING HOUSE DF ELECTRONCS INDSTR strDSN="ProviderMSDASQL, DRIVER=ISQL ServerI: SERVER=127.0.0. 1, DATABASE=Demo UID=chen PWD=123 Set connDemo= Server CreateObject("ADODB Connection") 建立记录集存放查询结果 Dim strSqlselectMessages Set rsMessages=Server CreateObject("ADODB. Recordset") strSqlselectMessages="SELECT* FROM guestbook messages WhERE id="& id rsMessages. Open strSqlselectMessages, connDemo htmI> table width="550" height=23"> font face="华文行楷"size="8">留言板 首页&nbsp,&nbsp,留言 管理

strDSN="Provider=MSDASQL;DRIVER={SQL Server};SERVER=127.0.0.1;DATABASE=Demo;UID=chen;PWD=123" Set connDemo = Server.CreateObject("ADODB.Connection") connDemo.Open strDSN '建立记录集,存放查询结果 Dim rsMessages Dim strSqlSelectMessages Set rsMessages = Server.CreateObject("ADODB.Recordset") strSqlSelectMessages="SELECT * FROM guestbook_messages WHERE id=" & id & "" rsMessages.Open strSqlSelectMessages,connDemo %> 功能模块“留言板” 留言板 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ; 首页&nbsp;&nbsp; 留言 &nbsp;&nbsp; 管理 &nbsp;&nbsp;

電子工業出版社 JEUISHING HOUSE DF ELECTRONCS INDSTR 日期:p4: 2.留言 用户可进入如图15.24所示的窗口,输入留言内容。输入留言实际上就是在 表中“添加记录 功模攻”言 如题,+:②的分收③历更图·回即可 到缺搜 留言板 百页置理 青留言 ·(标制40个宇杆以内 写密码成为保密用户,名字将被保护) 发言内容: 厂您丰a 理 图15.24留言 可以看出图1524与【例15.5】“添加记录”类似,所以可以引用【例15.5】的程序

主题: 作者: 日期: 内容: 2.留言 用户可进入如图 15.24 所示的窗口,输入留言内容。输入留言实际上就是在 guestbook-messages 表中“添加记录” 图 15.24 留言 可以看出 图 15.24 与【例 15.5】“添加记录”类似,所以可以引用【例 15.5】的程序

電子工業出版社 JEUISHING HOUSE DF ELECTRONCS INDSTR dd d.htm”与“add 功能模块“留言板” 留言板 &nbsp; &nbsp; &nbsp: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp: &nbsp; &nbsp; &nbsp; &nbsp; &nbs &nbsp;&anbs record gue.htm">留言 管理 /td〉 /tr> Form method=post action= add record_ gue. asp Ktable border="I height="26> 请留言 发言主题:input type=text name=txtSub ject size=”40"/> font face="宋体"size="2")*(标题限制40/td〉 td height="36">发言者:</td

“add_record.htm”与“add_record.asp”。 功能模块“留言板” 留言板 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p; 首页&nbsp;&nbsp; 留言 &nbsp;&nbsp; 管理 &nbsp;&nbsp;&nbsp;&nbsp; 请留言 发言主题: *(标题限制 40 个字符以内) 发言者:

電子工業出社 input type="text" name="txtUserName/>10密码(可选) (填写密码成为保留用户,名字将被保护) 发言内容: textarea name= txtContent rows="12" cols=83">/textarea> &nbsp; &nbsp; &nbs K/table> 100%>&nbsp: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsl /body> <add record gue.asp源程序〉 < Option Explicit 建立一个到数据源的连接 Dim conndemo ServerI: SERVER=127. 0. 0. 1: DATABASEDemo: UID=chen: PWD=123 et connDemo Server. CreateObject("ADODB Connection connDemo. Open strDSN 建立记录集,对用户进行操作

*(名字限制 10 个字符以内) 密 码(可选): (填写密码成为保留用户,名字将被保护) 发言内容: &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <% '建立一个到数据源的连接 Dim strDSN Dim connDemo strDSN="Provider=MSDASQL;DRIVER={SQL Server};SERVER=127.0.0.1;DATABASE=Demo;UID=chen;PWD=123" Set connDemo = Server.CreateObject("ADODB.Connection") connDemo.Open strDSN '建立记录集,对用户进行操作

電子工業出版社 JEUISHING HOUSE DF ELECTRONCS INDSTR Dim strsqlselectUsers Dim password userName=Request Form(txtUserName") Set rsUsers = Server. CreateOb ject("ADODB. Recordset") strSqlselectUsers="SELECT FROM guestbook users WHERE username=+user Name+ sUsers. Open strSqlselectUsers, connDemo, 1, 3 判断用户是否存在 判断密码是否正确 If password>trim(rsUsers("password"))Then Response, Write("密码错误") Response, end 判断是否输入了密码,如输入了密码,则新建立一个用户帐号 If password<> Then 接受表单输入数据,写入数据库表 rsUsers("password")=password rsUsers. Close set rsUsers=Nothing End if End if 建立记录集,新建发言 D Dim strSqlselectMessages Set rsMessages Server CreateObject("ADODB. Recordset") strSqlSelectMessages="SELECT FROM guestbook messages rsMessages. Open strSqISelectMessages, connDemo, 1, 3 接受表单输入数据,写入数据库表 rsMessages AddNew

Dim rsUsers Dim strSqlSelectUsers Dim userName Dim password userName=Request.Form("txtUserName") password=Request.Form("pwdPassword") Set rsUsers = Server.CreateObject("ADODB.Recordset") strSqlSelectUsers="SELECT * FROM guestbook_users WHERE username='"+userName+"'" rsUsers.Open strSqlSelectUsers, connDemo,1,3 '判断用户是否存在 If Not rsUsers.Eof Then '判断密码是否正确 If password<>trim(rsUsers("password")) Then Response.Write("密码错误") Response.end End If Else '判断是否输入了密码,如输入了密码,则新建立一个用户帐号 If password<>"" Then '接受表单输入数据,写入数据库表 rsUsers.AddNew rsUsers("username")=userName rsUsers("password")=password rsUsers.Update rsUsers.Close set rsUsers=Nothing End if End if '建立记录集,新建发言 Dim rsMessages Dim strSqlSelectMessages Set rsMessages = Server.CreateObject("ADODB.Recordset") strSqlSelectMessages="SELECT * FROM guestbook_messages" rsMessages.Open strSqlSelectMessages, connDemo,1,3 '接受表单输入数据,写入数据库表 rsMessages.AddNew

電子工業出版社 JEUISHING HOUSE DF ELECTRONCS INDSTR rsMessages ("username")=Request Form ("txtUser Name") rsMessages("password")=Request Form( txtPassword") mEssages("date")=NowO sMessages(sub ject")=Request Form("txtSub ject") rsMessages("content")=Request Form("txtContent") rsMessages. Update rsMessages. Close set rsMessages=Nothing 功能模块“留言板” 留言板 &nbsp; &nbsp; &nbsp; &nbsp: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbs 首页&nbsp;&nbsp;留言 &nbsp: &nbsp a href=" logon.asp">管理 &nbsp: &nbsp; &nbsp; &nbsp 留言己发布,点击< a href=" select record gue,asp")返回</a 3.管理员登陆验证

rsMessages("username")=Request.Form("txtUserName") 'rsMessages("password")=Request.Form("txtPassword") rsMessages("date")=Now() rsMessages("subject")=Request.Form("txtSubject") rsMessages("content")=Request.Form("txtContent") rsMessages.Update rsMessages.Close set rsMessages=Nothing %> 功能模块“留言板” 留言板 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p; 首页&nbsp;&nbsp; 留言 &nbsp;&nbsp; 管理 &nbsp;&nbsp;&nbsp;&nbsp; 留言已发布,点击返回 3.管理员登陆验证

点击下载完整版文档(DOC)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
共24页,试读已结束,阅读完整版请下载
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有