I have a very simple guestbook that adds data to a .txt file and displays it. But the problem is the .asp file refuses to update the .txt file eventhough text is added to it, why is this so? Another thing is that when I re-save the .asp file it will update it.
This is the code, and I guess it has something to do with the bold-formated text:
' If the script doesn't have anything posted to it we display the form
' otherwise we process the input and append it to the guestbook file.
If Request.Form.Count = 0 Then
What is form.count? and how do I change it... My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work
This is the code, and I guess it has something to do with the bold-formated text:
' If the script doesn't have anything posted to it we display the form
' otherwise we process the input and append it to the guestbook file.
If Request.Form.Count = 0 Then
Code:
' Display the entry form.
%>
<H3>Sign Our Guestbook:</H3>
<FORM ACTION="./gb.asp" METHOD="post">
<TABLE>
<TR>
<TD ALIGN="right"><B>Name:</B></TD>
<TD><INPUT TYPE="text" NAME="name" SIZE="15"></INPUT></TD>
</TR>
<TR>
<TD ALIGN="right"><B>Comment:</B></TD>
<TD><INPUT TYPE="text" NAME="comment" SIZE="35"></INPUT></TD>
</TR>
<TR>
<TD ALIGN="right"><B>E-Mail:</B></TD>
<TD><INPUT TYPE="text" NAME="email" SIZE="35"></INPUT></TD>
</TR>
</TABLE>
<INPUT TYPE="submit" VALUE="Sign Guestbook!"></INPUT>
</FORM>
<BR>
<H3>Today's Comments:</H3>
<!-- Instead of doing this in script, I simply include
the guestbook file as is -->
<!--#INCLUDE FILE="guestbook.txt"-->
<%
Else
' Log the entry to the guestbook file
Dim objFSO 'FileSystemObject Variable
Dim objFile 'File Object Variable
' Create an instance of the FileSystemObject
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
' Open the TextFile (FileName, ForAppending, AllowCreation)
Set objFile = objFSO.OpenTextFile(strFile, 8, True)
' Log the results
' I simply bold the name and do a <BR>.
' You can make it look however you'd like.
' Once again I remind readers that we by no means claim to
' be UI experts. Although one person did ask us if we had a
' graphic designer! I laughed so hard that I almost hurt myself!
If Request.Form("email") = "" THEN
objFile.Write "<B>"
objFile.Write Server.HTMLEncode(Request.Form("Name"))
objFile.Write "</a>:</B> "
Else
objFile.Write "<B><a href='mailto:"
objFile.Write Server.HTMLEncode(Request.Form("email"))
objFile.Write "' target='_new'>"
objFile.Write Server.HTMLEncode(Request.Form("Name"))
objFile.Write "</a>:</B> "
End If
objFile.Write Server.HTMLEncode(Request.Form("comment"))
objFile.Write "<BR>"
objFIle.Write "<hr>"
objFile.WriteLine ""
' Close the file and dispose of our objects
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing
' Tell people we've written their info
%>
<H3>Your comments have been written to the file!</H3>
<A HREF="./gb.asp">Back to the guestbook</A>
<%
End If
What is form.count? and how do I change it... My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work