In fact, it is not difficult to make a forum. The method we introduce here is only to meet the most basic functions of the forum. Other functions must be specific, but this can indeed bring hope to novices. It is a very powerful tutorial! The method is as follows:
1. Create files!
The simplest forum also has a few necessary documents:::
1. The database is used to store published posts! ------- Naming: BBS.MDB 2. If you have a database, you must connect to the database. This file is used to connect to the database: ---- name: conn.asp
3. Published the file of posts ---- Name: Say.asp
4. Save the files of the post-publishing posts ----- Naming: Save.asp
5. Display the file of the post title ------ name: index.asp
6. Display the file of the post content, that is, the page entered after clicking the title ----- name: show.asp
Second, the main content of each file
1. BBS.MDB
Open this database and build a table, named BBS
There are several fields in the table:
ID (automatically gives the post number), his data type is set to automatic number number
name (used to store the author), the data type is text
Title (the theme used to store posts), the data type is text
Body (used to store the content), the data type is the note
2. conn.asp
The source code is:
<%
Server.scripttimeout = 10
connstr = dbq =+server.mAppath (bbs.mdb)+; defaultdir =; driver = {microsoft access driver (*.mdb)};
set conn = server.createObject (adodb.connection)
conn.open connstr
%>
This file is to be connected to the database.
3. say.asp
The source code is:
<FORM METHOD = Post Action = Save.asp>
<p> Big name: <input type = text name = name size = 20> </p>
<p> Title: <input Type = Text Name = Title Size = 91> </p>
<p> Content: </p>
<p> <textarea rows = 11 name = body color = 97> </textarea> </p>
<p> </p>
<p> <input type = submit value = Submit name = b1> <input type = reset value = reset name = b2> </p>
</form>
Everyone should understand that this is the HTML syntax. Yes, it is simply that this is just the interface published
But pay attention to this sentence <FORM METHOD = Post Action = Save.asp>, he sends the contents of the user to the file of Save.asp, let's see the file of Save.asp below!
4. Save.asp
source code:
<!-#Include file = conn.asp->
<%name = replace (request.form (name), ',' ')
title = Replace (request.form (title), ',' ')
Body = Replace (request.form (body), ',' ')
%>
<%if name = or title = or body = then%>
Please <A HREF = Javascript: History.go (-1)> back </a> Fill in the full information to post a post!
<%Else%>
<%SAVEBBS = Conn.execute (Insert Into BBS (name, title, Body) Values ('& Name &', '& Title &', '& Body &')%>%>%>
Published success! <A href = index.asp> View post </a>
<%end if
set savebbs = nothing
%>
The first sentence: <!-#Include file = conn.asp->, which means inserting the con.asp file, that is, connect to the database!
The ASP statement must be included in the < % %> format, and the statement of inserting the file is not used.
The next few words:
name = replace (request.form (name), ',' ')
title = Replace (request.form (title), ',' ')
Body = Replace (request.form (body), ',' ')
Replace (request.form (name), ',' ') means data from text boxes named name in the form,
And name = replace (request.form (name), ',' ') is to store the sent data in the name variable,
If you are: abc123 = replace (request.form (name), ',' ')
It is the data from the text box named name in the form to store the data from the ABC123 variable
Next: if name = or title = or body = then
Determine whether there is no content in the name of Name, Title, and Body, that is, if so, this statement is executed:
Please <A HREF = Javascript: History.go (-1)> back </a> Fill in the full information to post a post!
This statement belongs to HTML syntax, everyone can understand!
<%Else%> means that when if ... then is not established (that is, everything has been filled in), execute the statement:
<%SAVEBBS = Conn.execute (Insert Into BBS (name, title, Body) Values ('& Name &', '& Title &', '& Body &')%>%>%>
Published success! <A href = index.asp> View post </a>
set save = conn.execute belongs to a fixed statement, but Savebbs can modify it by itself, and it is difficult to explain later:
Insert Into BBS (Name, Title, Body) means a table named BBS (the table that has been established when the database is established)
The name, title, body field is inserted, what is inserted? See the next values ('& name &', '& title &', '& body &')
Values means value
It is expressed in the format "
Finally: end if is the end of if ... then
set savebbs = nothing can be said to be closed:
set savebbs = conn.execute (Insert Into BBS (name, title, body) value