register a new user
存用户信息
<% name=REQUEST.FORM("name")
code=REQUEST.FORM("password")
Set Connection=Server.CreateObject("ADODB.Connection")
Connection.Open "author"
Set RS=Connection.Execute("SELECT * FROM author")
If Not RS.EOF Then %>
该用户名已被注册,请您重新注册新用户名!
<% Else
Connection.Execute("INSERT INTO author(authname,password) Values('" &name& "','" &code& "')")
RS.Close
Connection.Close %>
<% =name %> 您已注册成功!
<% End If %>
a sample form
bbs.asp
<% name=REQUEST.FORM("name")
code=REQUEST.FORM("code")
subject=REQUEST.FORM("subject")
content=REQUEST.FORM("content")
curdate=Date
curtime=Time
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
Set Connbbs = Server.CreateObject("ADODB.Connection")
Connbbs.Open "bbs"
Connbbs.Execute("INSERT INTO bbs(ID,authname,subject,content,adddate,addtime,answernum,topnum,visitnum) Values('" &number& "','"
&name& "','" &subject& "','" &content& "','" &curdate& "','" &curtime& "','" &manswernum& "','" &mtopnum& "',0)")
Connbbs.Close %>
<% =curdate & " " %><% =curtime & " 添加贴子 " %>
返回论坛
姓名:<% =name %>
主题:<% =subject %>
内容:<% =content %>
<% Else %>
您的用户名或密码出错,请您重输!
<% End If
RS.Close
Connection.Close %>
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) %>
主题:<% =RS(2) %>
内容:<% =RS(3) %>
------------------------------------------------------------------------------
<% resub="Re:" & RS(2)
mtopnum=RS(8)
RS.Close
Connection.Close %>
返回论坛
dispbbs.asp
<% 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) %>)
<% RSNEXT.MoveNext
Loop
RS.MoveNext
Loop
RSNEXT.Close
Conn.Close
RS.Close
Connection.Close %>