on Explicit
Public StrData(5) As String '' 用于存储表单内各项目的用户输入数据
Public CGI_QueryString As String '' 定义环境变量
Public Const STD_INPUT_HANDLE = -10&
Public Const STD_OUTPUT_HANDLE = -11&
Public hStdIn As Long '' 标准输入文件句柄
Public hStdOut As Long '' 标准输出文件句柄
Public Ent As String
'' 主函数
Sub Main()
Dim UrlString As String, Databook As String
Dim TempFileName As String, TempString As String
Dim Number As Single, I As Integer
Ent = vbCrLf
hStdIn = GetStdHandle(STD_INPUT_HANDLE)
hStdOut = GetStdHandle(STD_OUTPUT_HANDLE)
CGI_QueryString = Environ("QUERY_STRING") '' 读取返回字符
TempString = TempString + CGI_QueryString + vbCrLf
UrlString = UrlDecode(TempString)
TempString = FenGe(UrlString)
'' 获得一个随机数作为临时文件名
Randomize
Number = Int(10000 * Rnd + 100) '' 随机得到100到10000之间的整数
TempFileName = "YourWebSitePath1 \" & Number '' 注①
'' 取得留言簿文件名
Databook = "YourWebSitePath2 \databook.htm" '' 注②
Open TempFileName for Output As #1
Open Databook For Input As #2
'' 将留言簿中字符串"<!----->"前面的内容写入临时文件
Do
Line Input #2, TempString
Print #1, TempString
Loop While TempString <> "<!----->"
'' 检查客户端用户的输入项
If StrData(1) < " " Then
Send "Content-type:text/html" & Ent
Send "不要着急,您忘记填写名字了! "
Exit Sub
End If
If StrData(5) < " " Then
Send "Content-type:text/html" & Ent