Implementing Web BBS with ASP

Source: Internet
Author: User
Tags date reset return
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.


<body>
<form method= "POST" action= "/hosp/asp/register.asp" ><P>
<H2> for easy identification, please register a user name </H2>
User: <input type= "TEXT" name= "name" size= "><P>"
Password: <input type= "password" name= "password" size= "><P>"
<input type=submit value= "register" >
<input type=reset value= "Clear" >
<a href= "/hosp/asp/dispbbs.asp" > Return forum </a><P>
</body>

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.


<body background= "/hosp/images/backgrnd.gif" >
<form method= "POST" action= "/hosp/asp/bbs.asp" ><P>
Name: <input name= "name" size= "> Password: <input type=" password "name=" code "size=" "><P>
Theme: <input name= "Subject" size= "><P>"
Content:<p>
<textarea name= "Content" rows=20 cols=72></textarea><p>
<center><input type=submit value= "Release info" >
<input Type=reset value= "Clear Info" ></CENTER>
</FORM>
</body>

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:inetpubwwwroothospa



Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.