<% Option Explicit Dim ConnectString,sql,conn,rsEntry,by,subject,message,notfilled(1),badflag,count,replyid,root,newid,repliesFlag %> Houseview <% 'Assign form values to variables by = Request.Form("by") subject = Request.Form("subject") message = Request.Form("message") replyid = Request.Form("replyid") root = Request.Form("root") 'Check everything's been filled in, badflag determines whether error function is called badflag = 0 if subject = "" then notfilled(0) = "Subject" badflag = 1 end if if message = "" then notfilled(1) = "Message" badflag = 1 end if if badflag = 1 then posterror() end if 'Open connection and insert user details into the database ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("philbbs.mdb") Set conn = Server.CreateObject("ADODB.Connection") conn.open ConnectString message = RemoveHTMLTags(message) Set rsEntry = Server.CreateObject("ADODB.Recordset") rsEntry.open "messages", conn, 3, 3 rsEntry.AddNew rsEntry("by") = RemoveHTMLTags(by) rsEntry("subject") = RemoveHTMLTags(subject) rsEntry("message") = InsertLineBreaks(message) rsEntry("replyto") = replyid rsEntry("root") = root rsEntry.Update newid = rsEntry("id") if replyid <> 0 then rsEntry.close rsEntry.open "messages WHERE id = " & replyid, conn, 3, 3 rsEntry("replies") = rsEntry("replies") + 1 rsEntry.Update if replyid <> root then rsEntry.close rsEntry.open "messages WHERE id = " & root, conn, 3, 3 rsEntry("replies") = rsEntry("replies") + 1 rsEntry.Update end if repliesFlag = True else repliesFlag = False root = newid end if %>

Your message has been posted <%=by%>

<% rsEntry.close set rsEntry = nothing conn.close set conn = nothing %> <%Function posterror()%>

You have not filled in the following fields correctly:

<%for count = 0 to 1%> <%if notfilled(count) <> "" then%> <%=notfilled(count)%>
<%end if%> <%next%>

Please try again

<%Response.end End Function%> <%Function RemoveHTMLTags(sIn) Dim nCharPos, sOut, bInTag, sChar sOut = "" bInTag = False For nCharPos = 1 To Len(sIn) sChar = Mid(sIn, nCharPos, 1) If sChar = "<" Then bInTag = True End If If Not bInTag Then sOut = sOut & sChar If sChar = ">" Then bInTag = False End If Next RemoveHTMLTags = sOut End Function%> <%Function InsertLineBreaks(sIn) Dim charPos, sOut, curChar sOut = "" For charPos = 1 To Len(sIn) curChar = Mid(sIn, charPos, 1) if curChar = chr(13) then sOut = sOut + "
" else sOut = sOut + curChar end if Next InsertLineBreaks = sOut End Function%>