FormzProblem

1. Richard L Smith Guest

## FormzProblem

I am using a .asp script as a form handler<BR>this works well enough, except every new entry in the .txt file <BR>overwrites the previous entry. any ideas<BR>Thanks<BR>rls2@piedmont.net<BR>Function DecryptURL(strToDecode)<BR> strIn = strToDecode<BR> &#039result string<BR> strOut= ""<BR> intPos = Instr(strIn, "+") &#039get rid of + replace with spaces<BR>Do While intPos<BR> strleft = ""<BR> strRight = ""<BR> if intPos &#062; 1 Then strLeft = Left(strIn, intPos - 1)<BR> if intPos &#060; Len(strIn) then strRight = Mid(strIn, intPos + 1)<BR> strIn = strLeft & " " & strRight<BR> intPos = Instr(strIn, "+")<BR> intLoop = intLoop + 1<BR>Loop<BR>intPos = Instr(strIn, "%") &#039get ascii characters<BR>Do while intPos<BR> if intPos &#062; 1 Then strOut = strOut & Left(strIn, intPos - 1)<BR> strOut = strOut & Chr(CInt("&H" & Mid(strIn, intPos + 1, 2)))<BR> if intPos &#062; (Len(strIn) - 3) Then<BR> strIn = ""<BR>Else<BR> strIn - Mid(strIn, intPos = 3)<BR>End If<BR>intpos = Instr(strIn, "%") &#039find next ascii<BR>Loop<BR>DecryptURL = strOut & strIn<BR>End function<BR>&#039Create Dictionary object to hold the results<BR>Set objResult = CreateObject("Scripting.Dictionary")<BR>&#039Get form data<BR>strQuery = Request.Form<BR><BR>&#039parse the query string and fill the dictionary<BR>intSep = Instr(strQuery, "&")<BR>Do While intSep<BR>strKey = ""<BR>StrValue = ""<BR>strNVPair = Left(strQuery, intSep - 1)<BR>strQuery = Mid(strQuery, intSep + 1)<BR>intEqu = Instr(strNVPair, "=")<BR>if intEqu &#062; 1 Then strKey = DecryptURL(Left(strNVPair, intEqu-1))<BR>if intEqu &#060; Len(strNVPair) Then strValue = DecryptURL(Mid(strNVPair, intEqu+1))<BR> objResult.Add strKey, strValue &#039add to dictionary<BR> intSep = InStr(strQuery, "&")<BR>Loop<BR>strKey = ""<BR>strValue = ""<BR>intEqu = Instr(strQuery, "=")<BR>if intEqu &#062; 1 Then strKey = DecryptURL(Left(strQuery, intEqu-1))<BR>if intEqu &#060; Len(strQuery) Then strValue = DecryptURL(Mid(strQuery, intEqu+1))<BR>objResult.add strKey, strValue<BR>Function WriteToLogFile(strLogMessage)<BR> &#039On Error Resume Next &#039don&#039t stop if error<BR> &#039WriteToLogFile = False &#039default return value<BR> Const fsoForWriting = 2<BR> Dim objFSO<BR> Set objFSO = CreateObject("Scripting.FileSystemObject")<BR> Dim objLogFile<BR> Set objLogFile = objFSO.OpenTextFile("x:xxxxxxxxxxxxxxxx.txt", fsoForWriting)<BR> objLogFile.WriteLine "New Message"<BR> objLogFile.WriteLine(strLogMessage)<BR> objLogFile.Close<BR> objLogFile = Nothing<BR> objFSO = Nothing<BR> &#039f Err.number &#060;&#062; 0 Then WriteToLogFile = True<BR>End Function<BR>&#039now output the results<BR>strToLog = "Results From FORM ON " & Now() & vbCRLF<BR>strKeysArray = objResult.Keys<BR>strItemsArray = objResult.Items<BR>For intLoop = 0 to objResult.Count -1 <BR> strThisKey = strKeysArray(intLoop)<BR> strThisItem = strItemsArray(intLoop)<BR> Response.Write strThisKey & " = " & strThisItem & "<BR>"<BR> strToLog = strToLog & strThisKey & " = " & strThisItem & vbCRLF<BR>Next<BR>strToLog = strToLog & "---------------------------------------------" & vbCRLF <BR><BR>If WriteToLogFile(strToLog) then <BR> Response.Write "Message Recieved"<BR>&#039Else<BR>&#039Response.Write "Error in " & Err.Source<BR>&#039Response.Write "<BR>" & Err.description & "&#060;P&#062;"<BR>End If<BR>%&#062;

2. sam
Senior Member
Join Date
Dec 1969
Posts
866

## RE: FormzProblem

Try changing fsoForWriting to ForAppending or 8

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•