<center><br>
<font face="System, Ms Sans Serif, Angsana UPC, Thonburi, Krungthep" size="1">
Hi, you can type your message here Yes... any you like . .</font>
2.ไฟล์เขียนข้อมูลลง .txt ไฟล์
<%
' ถ้าป้องกันการ post ซ้ำ
' if session("sendtonight") = "sended" then
' response.redirect("display.asp")
' end if
thisfile = "add.asp"
msgfile = ".txt"
mode = Request.Form("mode")
if (mode="") then
Response.Redirect("main.asp")
else
'ถ้าตรวจสอบคำหยาบใส่ตรงนี้ได้เลย
savemode = "passbad"
polite = "yes"
end if
if (polite="yes") then
accmemo = ""
'จำกัดความยาว
msg1=Request.Form("memo")
n = len(msg1)
if n > 2400 then
adot="..."
memo2 = Left(msg1,2390) + adot
else
memo2 =msg1
end if
'ใส่ code ขึ้นบันทัดใหม่ และเว้นช่องว่าง
smemo = memo2
if (len(smemo)<1000) then
n = len(smemo)
else
n = 1000
end if
for i = 1 to n
char = mid(smemo,i,1)
ascii = asc(char)
if (ascii=13) then
char = "<br>"
elseif (ascii=32) then
char = " "
end if
accmemo = accmemo+char
next
'ไม่ให้ใช้ html
accinfo = ""
sinfo = trim(Request.Form("info"))
n = len(sinfo)
for i = 1 to n
char = mid(sinfo,i,1)
ascii = asc(char)
if (ascii=13) then
char = "<br>"
elseif (ascii=32) then
char = " "
elseif (ascii=60) then
char = "<"
elseif (ascii=62) then
char = ">"
end if
accinfo = accinfo+char
next
accfname = ""
sname = trim(Request.Form("fname"))
n = len(sname)
for i = 1 to n
char = mid(sname,i,1)
ascii = asc(char)
if (ascii=13) then
char = "<br>"
elseif (ascii=32) then
char = " "
elseif (ascii=60) then
char = "<"
elseif (ascii=62) then
char = ">"
end if
accfname = accfname+char
next
%>
<%
Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
TestFile = Server.MapPath ("text.txt")
On Error Resume Next
Set InStream= FileObject.OpenTextFile (TestFile, 1, false )
'จำกัดการ post ไว้
Dim lines(40)
LnCnt = 0
While not InStream.AtEndOfStream
InLine=Instream.ReadLine()
If Len(InLine) > 3 Then
LnCnt=LnCnt+1
lines(LnCnt) = InLine
End If
Wend