Arrochar tarbet and Ardlui Heritage Group - Web Site Guest Book
Guest Book > Add New Entry
Please tell us what you think about our site by filling in
the form below: - (email addresses will be kept confidential)
Please close this window when you've added your comment
HOME
<%
'FIRST WE DEFINE ALL THE VARIABLES WE ARE GOING TO USE
dim strFileName
dim strFileName2
dim file
dim fso
dim varName
dim varEmail
dim varFrom
dim varMessage
dim whoisit
dim thanksmate
dim lookfor1
dim lookfor2
lookfor1 = "http"
lookfor2 = "ringtone"
'THEN WE DEFINE THE NAME OF THE TEXT FILE WE WANT TO CREATE
'AND USE SERVER.MAPPATH TO SAY WHERE IT MUST GO
'WE THEN SET UP THE STANDARD CONSTANTS FOR READING WRITING ETC.
strFileName = server.mappath("/Guestbook/gbook.txt")
strFileName = "/content/BusinessHost/a/r/arrocharheritage.com/web/Guestbook/gbook.txt"
strFileName2 = "/content/BusinessHost/a/r/arrocharheritage.com/web/Guestbook/emails.txt"
Const ForReading = 1, ForWriting = 2, ForAppending = 8
'NOW WE CREATE OUR FSO AND CREATE THE TEXT FILE
'IF IT DOES NOT ALREADY EXIST.
set fso = server.CreateObject("Scripting.FileSystemObject")
set file = fso.OpenTextFile(strFileName,ForAppending ,true)
'NEXT WE GET THE INPUT FROM THE FORM USING REQUEST.FORM
'AND APPLY THAT INFO TO THE VARIABLES WE DEFINED EARLIER.
varName=Trim(request.form("name"))
varEmail=Trim(request.form("email"))
varFrom=Trim(request.form("from"))
varMessage=Trim(request.form("message"))
whoisit = date() & " " & time() & " " & varName & " from " & varFrom & ""
thanksmate = "Thank you " & varName & " from " & varFrom & " - your comment has been added and will appear on the site soon."
'IF SOME DOZY IDIOT JUST HITS THE SUBMIT BUTTON WITHOUT ENTERING
'A MESSAGE WE ARE GOING TO GET LOADS OF WHITE SPACE ON THE MESSAGE PAGE.
'TO STOP THIS WE WILL USE A SIMPLE IF - THEN ROUTINE TO CHECK THAT THE
'VARIABLES ACTUALLY HOLD SOME INFO.
varName=Trim(varName)
varFrom=Trim(varFrom)
varMessage=Trim(varMessage)
IF InStr(varMessage,lookfor1)=0 THEN
IF varName<>""THEN
IF varFrom<>""THEN
IF varMessage<>""THEN
file.write whoisit & vbCrlf
file.write varMessage & vbCrlf & "............................................................................................." & vbCrlf
Response.Write(thanksmate)
'CLOSE THE FILE AND FSO THEN END ALL THE IFS
file.close
set file = nothing
set fso = nothing
END IF
END IF
END IF
END IF
set fso = server.CreateObject("Scripting.FileSystemObject")
set file = fso.OpenTextFile(strFileName2,ForAppending ,true)
IF InStr(varMessage,lookfor1)=0 THEN
IF varEmail<>""THEN
file.write varEmail & vbCrlf
file.close
set file = nothing
set fso = nothing
END IF
END IF
%>