Click to See Complete Forum and Search --> : writing to a txt file part 2


jmaresca2005
05-04-2005, 09:33 AM
when i submit the form it writes to the txt file like it shouls but it displays on the actually asp page that the form is in. i want the form to write to the txt (with out the user knowing) and then writes a thank you message.


<%
If Request.Form.Count = 0 Then
%>
<html>
<title></title>
<head>

</head>
<body leftmargin=0 topmargin=0 marginwidth="0" marginheight="0" background="../images/tablebg.jpg">
<table align="center" width="50%" border="0">
<!--#include file="comments.txt"-->
</table>
<table align="center" width="50%" border="0">
<tr>
<td>
<form method="post" action="msgbox.asp">
<font face="verdana" size="2">Nick: </font><input type="text" name="nick"><br>
<font face="verdana" size="2">Comments: </font><input type="text" name="comments"><br>
<input type="submit" value="Send"></td>
</form>
</td>
</tr>
</table>
</body>
</html>

<%
Else

Dim strNick
Dim strComments
Dim strFile
Dim objFile
Dim objFSO

strFile = Server.MapPath("comments.txt")
strNick=Request.Form("nick")
strComments=Request.Form("comments")

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strFile, 8, True)

objFile.WriteLine " <tr><td><font face=""arial"" size=""2""><u>" & strNick & "</u>: </font><font face=""arial"" size=""2"">" & strComments & "</font></td></tr>"
objFile.Close
Response.AddHeader "REFRESH", "0; URL=msgbox.asp"
Set objFile = Nothing
Set objFSO = Nothing

End if
%>

jmaresca2005
05-04-2005, 10:08 AM
nevermind i figured it out