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
IF addm <> "" THEN IF email = "" THEN showError "You did not enter your email address", "post." END IF IF subject = "" THEN showError "You did not enter a subject for your message", "post." END IF IF message = "" THEN showError "You did not enter a message", "post." END IF IF INSTR( email, "." ) = 0 OR INSTR( email, "@" ) = 0 THEN showError "You did not enter a valid email address", "post." END IF
readyDBCon Set RS = Server.CreateObject( "ADODB.Recordset" ) RS.ActiveConnection = Con RS.CursorType = adOpenStatic RS.LockType = adLockOptimistic RS.Open "SELECT * FROM messages WHERE 1<>1", Con RS.AddNew RS( "m_email" ) = email RS( "m_subject" ) = subject RS( "m_message" ) = message RS( "m_reply" ) = addm RS.Update RS.Close IF addm <> "-1" THEN Con.Execute "UPDATE messages SET m_numreplies = m_numreplIEs+1 WHERE m_id=" & addm END IF END IF %> <Html> <head><title>frameset</title> <frameset rows="300,*"> <frame marginheight="3" marginwidth="5" frameborder="no" scrolling="yes" src="messagelist.? pg=<%=page%>"> <frame name="message" marginwidth="0" marginheight="0" frameborder="no" scrolling="auto" src="message.?id=<%=addm%>&pg=<%=page%>"> </frameset> </Html>
''''''''''''''''''''''''''' ' Declare Global Variables ''''''''''''''''''''''''''' DIM Con
SUB readyDBCon IF Con = "" THEN Set Con = Server.CreateObject( "adodb.Connection" ) Con.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath END IF END SUB
FUNCTION showUser( theEmail ) whereA = INSTR( theEmail, "@" ) showUser = Server.HtmlEncode( LEFT( theEmail, whereA - 1 ) ) END FUNCTION
FUNCTION formatOutput( theText ) theText = Server.HtmlEncode( theText ) theText = REPLACE( theText, vbNewline & vbNewline, "<p>" ) theText = REPLACE( theText, vbNewline, "<br>" ) formatOutput = theText END FUNCTION
sub showError( errorMessage, backpage ) %> <Html> <head><title>Problem</title></head> <body bgcolor="lightyellow"> <center> <table width="400" border=0 cellpadding=4 cellspacing=0> <tr> <td> <font face="Arial" size="4" color="red"><b> There was a problem with the message you entered:</b></font> <p><font face="Arial" size="3" color="blue"><b> <%=errorMessage%>. Please click the button below to correct this problem</b></font> <form method="post" action="<%=backpage%>"> <% for each thing in Request.Form %> <input name="<%=thing%>" type="hidden" value="<%=Server.HtmlEncode( Request( thing ) )%>"> <% next %> <input type="submit" value="Back"> </form>
</td> </tr> </table> </body> </head> <% Response.End end sub %>
Listing 5.0 - message. ------------------------------------ <!-- #INCLUDE FILE="discussfuncs." --> <% id = TRIM( Request( "id" ) ) IF id = "-1" THEN id = ""