<% Sub zAdd_Comment() '-- add 1 to the comments field in the news post this comment belongs to -- Dim zobjRS,zstrSQL Set zobjRS = Server.CreateObject("ADODB.Recordset") zstrSQL = "SELECT news.Comments FROM news WHERE news.PostID LIKE " & zintPostID zobjRS.Open zstrSQL, zobjConn, adOpenForwardOnly, adLockOptimistic, adCmdText If zobjRS.EOF Then 'bad post id, send em away Response.Redirect Request.ServerVariables("HTTP_REFERER") Response.End Else zobjRS("Comments") = zobjRS("Comments") + 1 zobjRS.Update End If zobjRS.Close '-- insert the comment into the database -- zobjRS.Open "comments", zobjConn, adOpenForwardOnly, adLockOptimistic, adCmdTable zobjRS.AddNew zobjRS("PostID") = zintPostID zobjRS("PostedBy") = zstrPostedBy zobjRS("PostedDate") = Now zobjRS("Comment") = zstrComment zobjRS.Update zobjRS.Close Set zobjRS = Nothing zobjConn.Close Set zobjConn = Nothing End Sub '-- get user input -- Dim zstrPostedBy,zstrComment,zintPostID,zvarAutoUrl,zvarSmilies zstrPostedBy = Trim(Request.Form("postedby")) zstrComment = Trim(Request.Form("comment")) zintPostID = Trim(Request.Form("postid")) 'news post id zvarAutoUrl = Trim(Request.Form("autoparseurl")) zvarSmilies = Trim(Request.Form("smilies")) If LCase(zvarAutoUrl) = "yes" Then zvarAutoUrl = True Else zvarAutoUrl = False End If If Comments_AllowSmilies And LCase(zvarSmilies) = "yes" Then zvarSmilies = True Else zvarSmilies = False End If '-- check postid is a number -- If zintPostID = "" Or Not IsNumeric(zintPostID) Then 'invalid postid, so forget the adding and send em back again Server.Transfer Request.ServerVariables("HTTP_REFERER") End If '-- check username If zstrPostedBy = "" Then zstrPostedBy = "Anonymous" Else '-- prepare the name given for database -- If Comments_UseLanguageFilter Then zstrPostedBy = zFilter_Language(zstrPostedBy) End If zstrPostedBy = Server.HTMLEncode(zstrPostedBy) End If If Len(zstrPostedBy) > 50 Then zstrPostedBy = (Left(zstrPostedBy,48) & "..") End If '-- check comment was given -- If zstrComment <> "" Then '-- prepare comment for db -- If Comments_UseLanguageFilter Then zstrComment = zFilter_Language(zstrComment) End If zstrComment = Server.HTMLEncode(zstrComment) zstrComment = zFilter(zstrComment,zvarAutoUrl,Comments_AllowUBB,zvarSmilies,Comments_AllowImages) '-- add comment to db -- Call zAdd_Comment() End If '-- send user back to page they came from -- 'Server.Transfer Request.ServerVariables("HTTP_REFERER") Response.Redirect Request.ServerVariables("HTTP_REFERER") %>