传统的网页BBS大多是采用CGI模式实现的,它的实现要求编程者既要掌握编程语言如Perl或C等,又要了解关于CGI模式的各项技术内容,因此要制作自己的网页BBS确实困难不小。ASP(Active Server Pages 动态服务器主页)的出现,使我们眼前一亮,能不能利用ASP实现网页BBS呢?回答当然是肯定的。ASP的诱人之处就在于它提供了一种简单易学的脚本,并带有许多内置的对象,从而提供了一条简捷的编程之路。
Set Connection = Server.CreateObject("ADODB.Connection") Connection.Open "author" Set RS = Connection.Execute("SELECT * FROM author WHERE authname='" &name& "' AND password='" &code& "'")
If Not RS.EOF Then
Set FileObject = Server.CreateObject("Scripting.FileSystemObject") Set InStream = FileObject.OpenTextFile ("c:\inetpub\wwwroot\hosp\asp\data.id", 1, False, False) number = Cstr(InStream.Readline+1) Set OutStream = FileObject.CreateTextFile ("c:\inetpub\wwwroot\hosp\asp\data.id", True, False) OutStream.WriteLine number If Request.QueryString("ID")="" Then manswernum=number Else manswernum=Request.QueryString("ID") End If If Request.QueryString("topnum")="" Then mtopnum=number Else mtopnum=Request.QueryString("topnum") End If Set OutStream = Nothing
<% Else %> 您的用户名或密码出错,请您重输! <% End If RS.Close Connection.Close %>
5、帖子具体内容的显示和回复 detail.asp
bbs.asp
<% idnum=Request.QueryString("ID") Set Connection=Server.CreateObject("ADODB.Connection") Connection.Open "bbs" Set RS=Connection.Execute("SELECT * FROM bbs WHERE ID='" &idnum& "'") %> 姓名:<% =RS(1) %>
<% Set Connection=Server.CreateObject("ADODB.Connection") Connection.Open "bbs" Set RS=Connection.Execute("SELECT * FROM bbs WHERE ID=answernum ORDER BY ID DESC") Set Conn=Server.CreateObject("ADODB.Connection") Conn.Open "bbs" Set RSNEXT=Conn.Execute("SELECT * FROM bbs") Do While not RS.EOF %> <% =RS(0) %> <% =RS(2) %> -<% =RS(1) %> <% =RS(4) &" " %><% =RS(7) %>(<% =RS(5) %>)
<% Set RSNEXT=Conn.Execute("SELECT * FROM bbs WHERE topnum<>ID AND opnum='" &RS(0)& "' ORDER BY ID ASC") Do While Not RSNEXT.EOF %> <% =RSNEXT(0) %> Re<% RSNEXT(6) %>:<% =RSNEXT(2) %> -<% =RSNEXT(1) %> <% =RSNEXT(4) &" " %><% =RSNEXT(7) %>(<% =RSNEXT(5) %>)
查看所有0条评论>>