det kan ske jeg har forklaret mig selv underligt...
<% Option Explicit %>
<!--#include file="common.inc" -->
<%
'Set the response buffer to true as we maybe redirecting
Response.Buffer = True
'Dimension variables
Dim rsSmut 'Database Recordset holding the smut table
Dim rsAddNewComments 'Database recordset to add new comments
Dim strInputNavn
Dim strInputAdresse
Dim strInputPostnummer
Dim strInputBy
Dim strInputEmail
Dim strInputMobil
Dim strInputTlf
Dim strInputKaelenavn
Dim strInputRumbo
Dim strInputSavne
Dim strInputMotto
Dim strInputElevnr
Dim strInputBummert
Dim strInputSavne2
Dim strInputMotto2
Dim strInputKaelenavn2
Dim strInputBummert2
Dim strInputSavne3
Dim strInputMotto3
Dim strInputKaelenavn3
Dim strInputBummert3
Dim saryCommentWord 'Array to hold each word in the comments enetred by the user
Dim intCheckWordLengthLoopCounter 'Loop counter
Dim intWordLength 'Holds the length of the word to be checked
Dim blnWordLenthOK 'Boolean set to False if any words in the description are above 30 characters
Dim intLongestWordLength 'Holds the number of characters in the longest word entered in the description
strInputNavn = Request.Form("navn")
strInputAdresse = Request.Form("adresse")
strInputPostnummer = Request.Form("postnummer")
strInputBy = Request.Form("by")
strInputEmail = Request.Form("email")
strInputMobil = Request.Form("mobil")
strInputTlf = Request.Form("tlf")
strInputKaelenavn = Request.Form("kaelenavn")
strInputBummert = Request.Form("bummert")
strInputElevnr = Request.Form("elevnr")
strInputRumbo = Request.Form("rumbo")
strInputSavne = Request.Form("savne")
strInputMotto = Request.Form("motto")
strInputKaelenavn2 = Request.Form("kaelenavn2")
strInputBummert2 = Request.Form("bummert2")
strInputSavne2 = Request.Form("savne2")
strInputMotto2 = Request.Form("motto2")
strInputKaelenavn3 = Request.Form("kaelenavn3")
strInputBummert3 = Request.Form("bummert3")
strInputSavne3 = Request.Form("savne3")
strInputMotto3 = Request.Form("motto3")
'Split-up each word in the comments from the user to check that no word entered is over 50 characters
saryCommentWord = Split(Trim(strInputBummert), " ")
'Initialse the word length variable
blnWordLenthOK = True
'Loop round to check that each word in the comments entered by the user is not above 50 characters
For intCheckWordLengthLoopCounter = 0 To UBound(saryCommentWord)
'Initialise the intWordLength variable with the length of the word to be searched
intWordLength = Len(saryCommentWord(intCheckWordLengthLoopCounter))
'Get the number of characters in the longest word
If intWordLength => intLongestWordLength Then
intLongestWordLength = intWordLength
End If
'If the word length to be searched is more than or equal to 50 then set the blnWordLegthOK to false
If intWordLength => 50 Then
blnWordLenthOK = False
End If
Next
'Change my own codes for bold and italic HTML tags back to the normal satndrd HTML tags now that the check for unwated HTML tags is over
strInputBummert = Replace(strInputBummert, "[B]", "<b>", 1, -1, 1)
strInputBummert = Replace(strInputBummert, "[/B]", "</b>", 1, -1, 1)
strInputBummert = Replace(strInputBummert, "[I]", "<i>", 1, -1, 1)
strInputBummert = Replace(strInputBummert, "[/I]", "</i>", 1, -1, 1)
strInputBummert = Replace(strInputBummert, "[U]", "<u>", 1, -1, 1)
strInputBummert = Replace(strInputBummert, "[/U]", "</u>", 1, -1, 1)
'Change the emotion symbols for the path to the relative smiley icon
strInputBummert = Replace(strInputBummert, ":)", "<img src=""guestbook_images/smiley1.gif"" width=""17"" height=""17"">")
strInputBummert = Replace(strInputBummert, ";)", "<img src=""guestbook_images/smiley2.gif"" width=""17"" height=""17"">")
strInputBummert = Replace(strInputBummert, ":o", "<img src=""guestbook_images/smiley3.gif"" width=""17"" height=""17"">")
strInputBummert = Replace(strInputBummert, ":D", "<img src=""guestbook_images/smiley4.gif"" width=""17"" height=""17"">")
strInputBummert = Replace(strInputBummert, ":errr:", "<img src=""guestbook_images/smiley5.gif"" width=""17"" height=""17"">")
strInputBummert = Replace(strInputBummert, ":(", "<img src=""guestbook_images/smiley6.gif"" width=""17"" height=""17"">")
strInputBummert = Replace(strInputBummert, "X(", "<img src=""guestbook_images/smiley7.gif"" width=""17"" height=""17"">")
'Replace the vb new line code for the HTML new break code
strInputBummert = Replace(strInputBummert, vbCrLf, "<br>")
'Get rid of repeated return key hits so there arn't two many new lines going half way down the page (<br> is the HTML tag for new line)
'Loop though the comments entered by the user till all cases of two new lines togather are replaced by one new line
Do While InStr(1, strInputBummert, "<br><br>" ,vbTextCompare) > 0
'Replace <br><br> with one case of <br>
strInputBummert = Replace(strInputBummert , "<br><br>", "<br>")
Loop
'Create recorset object
Set rsSmut = Server.CreateObject("ADODB.Recordset")
'Replace swear words with other words with ***
'Initalise the SQL string with a query to read in all the words from the smut table
strSQL = "SELECT tblSmut.* FROM tblSmut;"
'Open the recordset
rsSmut.Open strSQL, strCon
'Loop through all the words to check for
'Reset recordset
Set rsSmut = Nothing
'Write to the database if there are no unwanted HTML tags or the word lengths in the commets entered by the user are OK
If blnWordLenthOK = True Then
'Create recorset object
Set rsAddNewComments = Server.CreateObject("ADODB.Recordset")
'Initalise the SQL string with a query to read in all the comments from the database
strSQL = "SELECT kommentarer.* FROM kommentarer;"
'Set the cursor type property of the record set to Dynamic so we can navigate through the record set
rsAddNewComments.CursorType = 2
'Set the Lock Type for the records so that the record set is only locked when it is updated
rsAddNewComments.LockType = 3
'Open the recordset
rsAddNewComments.Open strSQL, strCon
'Add a new record to the recordset
rsAddNewComments.AddNew
rsAddNewComments.Fields("rumbo") = strInputRumbo
rsAddNewComments.Fields("elevnr") = strInputElevnr
rsAddNewComments.Fields("navn") = strInputNavn
rsAddNewComments.Fields("adresse") = strInputAdresse
rsAddNewComments.Fields("postnummer") = strInputPostnummer
rsAddNewComments.Fields("by") = strInputBy
rsAddNewComments.Fields("email") = strInputEmail
rsAddNewComments.Fields("mobil") = strInputMobil
rsAddNewComments.Fields("tlf") = strInputTlf
rsAddNewComments.Fields("kaelenavn") = strInputKaelenavn
rsAddNewComments.Fields("bummert") = strInputBummert
rsAddNewComments.Fields("savne") = strInputSavne
rsAddNewComments.Fields("motto") = strInputMotto
rsAddNewComments.Fields("kaelenavn2") = strInputKaelenavn
rsAddNewComments.Fields("bummert2") = strInputBummert
rsAddNewComments.Fields("savne2") = strInputSavne
rsAddNewComments.Fields("motto2") = strInputMotto
rsAddNewComments.Fields("kaelenavn3") = strInputKaelenavn
rsAddNewComments.Fields("bummert3") = strInputBummert
rsAddNewComments.Fields("savne3") = strInputSavne
rsAddNewComments.Fields("motto3") = strInputMotto
'Update the database with the new recordset
rsAddNewComments.Update
'Requery the database to make sure that the new comments have been added
'This will make the script wait until Database has updated itself as sometimes Access can be a little slow at updating
rsAddNewComments.Requery
'Reset Sever Objects
Set adoCon = Nothing
Set rsAddNewComments = Nothing
'Return to the guestbook
Response.Redirect "tak.asp?PagePosition=1"
End If
%>
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Sign the Guest Book - Error</TITLE>
<!-- Display an error message -->
<script language="JavaScript">
<!-- Hide from older browsers...
//Display an error message in an alert box
window.alert('Sorry one of the words used in your comments has <% = intLongestWordLength %> characters\nPlease shortern the length of this word to below 50 characters');
//Return the user to there comments
self.location.href='java script:history.back(1)';
// -->
</script>
</head>
<body bgcolor="<% = strBgColour %>" text="<% = strTextColour %>" link="<% = strLinkColour %>" vlink="<% = strVisitedLinkColour %>" alink="<% = strActiveLinkColour %>">
</body>
</html>