%
'/----------------------------------------------\
'>********** Please choose you colors:**********<
'\----------------------------------------------/
HeadingCellBgColor="#000099"
HeadingCellTextColor="#ffffff"
CellBgColor="#f0f0f0"
CellTextColor="#000000"
%>
My guestbook
<%
'/----------------------------------------------\
'>********* Data selected or requested *********<
'\----------------------------------------------/
Flag = Request.form("Flag")
If Flag = 1 then
Name = Request.form("Name")
Email = Request.form("Email")
Url = Request.form("Url")
Comment = Request.form("Comment")
Comment = server.HTMLencode(Comment) 'Do not allow HTML
Comment = Replace(Comment,VbCrlf,"
")
'************************************************
'/----------------------------------------------\
'>*************** Validation *******************<
'\----------------------------------------------/
errmsg=""
If Replace(Name," ","") = "" then errmsg = errmsg & "- Name is missing
"
If Replace(Email," ","") = "" then
errmsg = errmsg & "- Email is missing
"
ElseIf InStr(Email,"@")=0 then
'all emails contain an at sign eg. you@you.com
errmsg = errmsg & "- Email is invalid
"
ElseIf InStr(Email,".")=0 then
'all emails contain a dot eg. you@you.com
errmsg = errmsg & "- Email is invalid
"
End If
'Url is not required
If Replace(Comment," ","") = "" then errmsg = errmsg & "- Comment is missing
"
errmsg = errmsg & "
"
If NOT errmsg ="" then
%>
Following errors were detected:
<%= errmsg %>
Please click the back button on your browser, or click here and fix these errors.
<%
Response.end
End If
'************************************************
'/----------------------------------------------\
'>********** The new record is created *********<
'\----------------------------------------------/
'Comment next line out if you want the new record to appear as the last record in the guestbook
Newrecord = ""
Newrecord = Newrecord & "" & VbCrlf
Newrecord = Newrecord & "" & VbCrlf
Newrecord = Newrecord & "| Date: | " & now & " |
" & VbCrlf
Newrecord = Newrecord & "| Name: | " & Name & " |
" & VbCrlf
Newrecord = Newrecord & "| Email: | " & Email & " |
" & VbCrlf
If NOT Url = "" then
Newrecord = Newrecord & "| Own Url: | " & Url & " |
" & VbCrlf
End If
Newrecord = Newrecord & "| Comments: |
" & VbCrlf
Newrecord = Newrecord & "| " & Comment & " |
" & VbCrlf
Newrecord = Newrecord & "
" & VbCrlf & VbCrlf
If Instr(Newrecord,"") = 0 then
Newrecord = Newrecord & ""
End If
'************************************************
'/----------------------------------------------\
'>********** Edit data.txt *********************<
'\----------------------------------------------/
fn = server.mappath("data.txt") 'Find data.txt on server
Set fs = CreateObject("Scripting.FileSystemObject") 'Create the FileSystem object
Set htmlfile = fs.OpenTextFile(fn, 1, 0, 0) 'Open data.txt
code = htmlfile.ReadAll 'Read contents of file
htmlfile.close 'Close data.txt
set htmlfile = nothing
code = Replace(Code,"",Newrecord) 'Add the new record
Set htmlfile = fs.CreateTextFile(fn) 'ReCreate data.txt
htmlfile.write code 'Write contents
htmlfile.close 'Close data.txt
set htmlfile = nothing
set fs = nothing 'Close FileSystem object
' *****************************************
%>
Thank you for signing my guestbook
View guestbook
<%
Else
%>
Sign my guestbook
<%
End If
%>