|
hyBook - A Simple Guestbook Application
Part:
1
2
3
4
5
6
7
8
9
10
11
12
13
(Continued from previous part...)
Here is the source code of default.asp:
<!--#include file='_config.inc'-->
<%
' comment_default.asp
'
' Comment default page
' hyBook version 2006.01.01
' Copyright (c) 2006 by Dr. Herong Yang, http://www.herongyang.com/
Dim bgShowTopic, bgShowCommentList, bgShowCommentNew, ngTopicID
Dim sgError, sgNotice
Dim sgName, sgEmail, sgContent
bgShowTopic = True
bgShowCommentList = True
bgShowCommentNew = True
%>
<!--#include file='_template.inc'-->
<%
Sub opening
dbConnect
' Checking query string and form data
sTopicID = myTrim(Request.Querystring("TopicID"),6)
ngTopicID = Clng(sTopicID)
If Request.Form("submit") = "Submit" Then
sgName = myTrim(Request.Form("Name"),40)
sgEmail = myTrim(Request.Form("Email"),40)
sgContent = myTrim(Request.Form("Content"),2000)
sTopicID = myTrim(Request.Form("TopicID"),6)
ngTopicID = Clng(sTopicID)
sgName = removeHTML(sgName)
sgContent = removeHTML(sgContent)
bOK = True
' Checking submit limit
If bOK Then
bOK = validateSubmitLimit
End If
' Checking ngTopicID
If bOK Then
bOK = validateTopicID
End If
' Checking required values
If bOK Then
bOK = validateRequiredValue
End If
' Checking to stop re-post
If bOK Then
bOK = validateRepost
End If
' Submit data
If bOK Then
sName = Replace(sgName, "'", "''")
sEmail = Replace(sgEmail, "'", "''")
sContent = Replace(sgContent, "'", "''")
sAddress = Request.ServerVariables("REMOTE_ADDR")
sSQL = "INSERT INTO [hyComment] ([Name]," _
& " [Email]," _
& " [TopicID]," _
& " [Content]," _
& " [Timestamp]," _
& " [IpAddress])" _
& " VALUES ('" & sName & "'" _
& ", '" & sEmail & "'" _
& ", " & ngTopicID _
& ", '" & sContent & "'" _
& ", #" & date() & "#" _
& ", '" & sAddress & "')"
If bgDebug Then
ogDebug.WriteLine("sSQL = " & sSQL)
End If
ogConn.Execute(sSQL)
sgNotice = "Your comment has been added. Thank you!"
sgName = ""
sgEmail = ""
sgContent = ""
Else
sgName = Server.HTMLEncode(sgName)
sgEmail = Server.HTMLEncode(sgEmail)
sgContent = Server.HTMLEncode(sgContent)
End If
End If
If ngTopicID = 0 Then
ngTopicID = ngDefaultTopicID
End If
End Sub
(Continued on next part...)
Part:
1
2
3
4
5
6
7
8
9
10
11
12
13
|