Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

guestbook refuses to update

Status
Not open for further replies.

801119

Programmer
Apr 10, 2000
311
SE
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
Code:
	' Display the entry form.
	%>
	<H3>Sign Our Guestbook:</H3>
	<FORM ACTION=&quot;./gb.asp&quot; METHOD=&quot;post&quot;>
	<TABLE>
		<TR>
		<TD ALIGN=&quot;right&quot;><B>Name:</B></TD>
		<TD><INPUT TYPE=&quot;text&quot; NAME=&quot;name&quot; SIZE=&quot;15&quot;></INPUT></TD>
		</TR>
		<TR>
		<TD ALIGN=&quot;right&quot;><B>Comment:</B></TD>
		<TD><INPUT TYPE=&quot;text&quot; NAME=&quot;comment&quot; SIZE=&quot;35&quot;></INPUT></TD>
		</TR>
		<TR>
		<TD ALIGN=&quot;right&quot;><B>E-Mail:</B></TD>
		<TD><INPUT TYPE=&quot;text&quot; NAME=&quot;email&quot; SIZE=&quot;35&quot;></INPUT></TD>
		</TR>
	</TABLE>
	<INPUT TYPE=&quot;submit&quot; VALUE=&quot;Sign Guestbook!&quot;></INPUT>
	</FORM>

	<BR>

	<H3>Today's Comments:</H3>
	<!-- Instead of doing this in script, I simply include
			the guestbook file as is -->
	<!--#INCLUDE FILE=&quot;guestbook.txt&quot;-->
	<%
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(&quot;Scripting.FileSystemObject&quot;)
	' 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(&quot;email&quot;) = &quot;&quot; THEN
		objFile.Write &quot;<B>&quot;
		objFile.Write Server.HTMLEncode(Request.Form(&quot;Name&quot;))
		objFile.Write &quot;</a>:</B> &quot;
	Else
		objFile.Write &quot;<B><a href='mailto:&quot;
		objFile.Write Server.HTMLEncode(Request.Form(&quot;email&quot;))
		objFile.Write &quot;' target='_new'>&quot;
		objFile.Write Server.HTMLEncode(Request.Form(&quot;Name&quot;))
		objFile.Write &quot;</a>:</B> &quot;
	End If
		objFile.Write Server.HTMLEncode(Request.Form(&quot;comment&quot;))
		objFile.Write &quot;<BR>&quot;
		objFIle.Write &quot;<hr>&quot;
		objFile.WriteLine &quot;&quot;

	' 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=&quot;./gb.asp&quot;>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
 
The syntax should be :

If Request.Form(&quot;Count&quot;) = 0 Then Regards

Big Dave

davidbyng@hotmail.com


** If I am wrong I am sorry, but i'm only trying to help!! **

 
no hang on thats not right :

If Request.Form(&quot;name&quot;) = &quot;&quot; Then Regards

Big Dave

davidbyng@hotmail.com


** If I am wrong I am sorry, but i'm only trying to help!! **

 
Nope, sorry, neither of them worked... anyother idea? 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
 
The problem isn't the first part... but the one that prints the guestbook, what has been written before! 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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top