用Access制作一个功能完善的论坛(源程序)
2018-09-06 12:45
To view a live demonstration of this forum, click View Demo.
To create this forum on your server, you will need to create a Microsoft access(小型网站之最爱) Database named
discuss.mdb. You will also need to create a single table in this database named messages that has the
following fields:
m_id -- An autonumber field
m_email -- A text field
m_subject -- A text field
m_message -- A Memo field
m_entrydate -- A Date/Time field with default value of NOW()
m_numReplies -- A Number field with default value of 0
m_reply -- A Number field with default value of -1
Listing 1.0 - discuss.asp
-----------------------------------
-----------------------------------------
Listing 2.0 - discussframes.asp
-------------------------------------------------
<!-- #INCLUDE FILE=discussfuncs.asp -->
<%
page = TRIM( request( pg ) )
addm = TRIM( request( addm ) )
email = TRIM( request( email ) )
subject = TRIM( request( subject ) )
message = TRIM( request( message ) )
THEN
IF email = THEN
showError You did not enter your email address, post.asp
END IF
IF subject = THEN
showError You did not enter a subject for your message, post.asp
END IF
IF message = THEN
showError You did not enter a message, post.asp
END IF
IF INSTR( email, . ) = 0 OR INSTR( email, @ ) = 0 THEN
showError You did not enter a valid email address, post.asp
END IF
readyDBCon
Set RS = Server.CreateObject( ADODB.Recordset )
RS.ActiveConnection = Con
RS.CursorType = adOpenStatic
RS.LockType = adLockOptimistic
1, Con
RS.AddNew
RS( m_email ) = email
RS( m_subject ) = subject
RS( m_message ) = message
RS( m_reply ) = addm
RS.Update
RS.Close
-1 THEN
Con.Execute UPDATE messages SET m_numreplies = m_numreplies+1 WHERE m_id= addm
END IF
END IF
%>
<frame marginheight=3 marginwidth=5 frameborder=no scrolling=yes src=messagelist.asp?
<frame name=message marginwidth=0 marginheight=0 frameborder=no scrolling=auto
------------------------------------------------------
Listing 3.0 - discussfuncs.asp
-------------------------------------------------------
<%
dbPath = d:discuss.mdb
messagesApage = 5
Define Constants
adOpenStatic = 3
adLockOptimistic = 3
Declare Global Variables
DIM Con
SUB readyDBCon
IF Con = THEN
下一篇:ASP 3.0高级编程(二)
文章标题:用Access制作一个功能完善的论坛(源程序)
文章链接:http://soscw.com/index.php/essay/10638.html