Web pages of traditional Web BBS is mostly implemented by CGI, its implementation requires programmers to master programming languages such as Perl or C, but also to understand the CGI model of the various technical content, so to make their own web BBs really difficult. ASP (Active Server Pages Dynamic Server home page), so that we see a bright, can use ASP to achieve Web BBS it? Of course the answer is yes. The allure of ASP is that it provides a simple and easy to learn script, with many built-in objects, thus providing a simple way of programming.
The BBS mainly by the user registration (browser-side), user registration (server-side), plus posts (browser-side), add posts (server side), post specific content of the display and reply, as well as the display of all posts six components, The user information is stored in the database Author.mdb, the post is stored in the database Bbs.mdb. They are all Access databases, which are shown in tables 1, 2, respectively.
Table 1 Author.mdb
Field name data type length description
AuthName Text 24 User name
Password Text 10 password
Table 2 Bbs.mdb
Field name data type length description
ID Text 4 Number of posts
AuthName Text 24 User name
Subject Text 80 Themes
Content Comment Contents
Adddate Date/Time Posted date
Visitnum Digital long-integer visitors
Number of Answernum text 4 reply post
(Default is the number of itself)
Addtime Date/Time Add paste time
Topnum Text 4 Number of the first level reply post
The implementation method is as follows, where ASP files and databases are stored in "/hosp/asp", other HTM
Files are stored in "/hosp" Files, and img files are stored in "/hosp/images".
1, user registration (browser-side) login.htm: the user input relevant information, through the form sent to the service
The service device.
2, user registration (server-side) Register.asp: Use Request.Form ("form field name") to receive form information, using ADO technology and database Author.mdb connection, and the form information into the Author.mdb.
<body>
<!--the username and password entered in the client's browser-->
<% Name=request. FORM ("name")
Code=request. FORM ("password")
<!--connection with Author.mdb-->
Set connection=server.createobject ("ADODB. Connection ")
Connection.Open "Author"
Set Rs=connection.execute ("SELECT * from author")
<!--if the username already exists, please lose it or save it in the database-->
If not RS. EOF Then%>
The username has been registered, please <a href= "/hosp/login.htm" > Register </a> new username!
<% Else
Connection.Execute ("INSERT into author (authname,password) Values (' &name&" ', ' "&code&") ")
Rs. Close
Connection.close%>
<center><b><% =name%></b> You have registered successfully!<p>
<a href= "/hosp/asp/dispbbs.asp" > Return forum </a></CENTER>
<% End If%>
</body>
3, add posts (browser-side) bbs_add.htm: User input to be added to the information related to the post, and uploaded to the server.
4, add post (server side) Bbs.asp: Receive post content, and deposit in Bbs.mdb.
<body>
<% Name=request. FORM ("name")
Code=request. FORM ("code")
Subject=request. FORM ("Subject")
Content=request. FORM ("content")
Curdate=date
Curtime=time
<!--connection with Author.mdb-->
Set Connection = Server.CreateObject ("ADODB. Connection ")
Connection.Open "Author"
Set RS = Connection.Execute ("SELECT * from author WHERE authname= '" &name& "' and password= '" &code& ' ")
<!--determine if the user name and password match-->
If not RS. EOF Then
<!--Open the data file, which holds the number of posts, each add a post, number plus 1-->
Set FileObject = Server.CreateObject ("Scripting.FileSystemObject")
Set instream = Fileobject.opentextfile ("C:inetpubwwwroothospaspdata.id", 1, false, False)
Number = Cstr (instream.readline+1)
Set OutStream = Fileobject.createtextfile ("C:inetpubwwwroothospaspdata.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
<!--connect with Bbs.mdb and deposit post information into the database-->
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& ', ' ', ' amp;manswernum& "', '" &mtopnum& "', 0")
Connbbs.close%>
<% =curdate & ""%><% =curtime & "Add posts"%>
<a href= "http://nt-server/hosp/asp/dispbbs.asp" > Return forum </a><P>
Name: <% =name%><p>
Topic: <% =subject%><p>
Content: <% =content%><p>
<% Else%>
Your username or password is wrong, please lose again!
<% End If
Rs. Close
Connection.close%>
</body>
5, the post specific content display and reply detail.asp
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.