<%
'-------------------------------------------------------------------------------
email=Request.Form("email")
response.Write(email)
If IsValidEmail(email) Then
Set objFS=Server.CreateObject("Scripting.FileSystemObject")
Set objRF=objFS.OpenTextFile(Server.MapPath("maillist.txt"), 1) ' ForReading 1
Dim i
i = 0
Do While Not objRF.AtEndOfstream
Data = objRF.ReadLine
If (email = Data) Then
i = i+1
End If
Loop
objRF.Close
Set objRF=Nothing
Set objFS=Nothing
if i = 0 then
Set objFS=Server.CreateObject("Scripting.FileSystemObject")
Set objRF=objFS.OpenTextFile(Server.MapPath("maillist.txt"), 8) ' ForAppending=8
objRF.WriteLine email
objRF.Close
Set objRF=Nothing
Set objFS=Nothing
Response.Write "<script language='JavaScript'>"
Response.Write "alert('ทางเราได้รับข้อมูลเรียบร้อยแล้ว')"
Response.Write "</script>"
Else
Response.Write "<script language='JavaScript'>"
Response.Write "alert('email นี้ได้ลงทะเบียนไว้แล้ว')"
Response.Write "</script>"
End If
Else
Response.Write "<script language='JavaScript'>"
Response.Write "alert('กรุณากรอกข้อมูลให้ถูกต้อง')"
Response.Write "</script>"
End If
Function IsValidEmail(email)
Dim LenEmail
LenEmail = 0
LenEmail = Len(email)
If (LenEmail >= 8) Then
If(InStr(email," " ) )Then
IsValidEmail=False
Else
If (Instr(email,"."))Then
If (Instr(email,"@")) Then
IsValidEmail=True
Else IsValidEmail=False
End If
Else IsValidEmail=False
End If
End If
Else IsValidEmail=False
End If
End Function
'-------------------------------------------------------------------------------
%>
Tag : - - - -
Date :
14 มิ.ย. 2550 05:57:01
By :
designnext
View :
1879
Reply :
1
No. 1
Guest
Code (ASP)
<% Option Explicit %>
<html>
<head>
<title>ThaiCreate.Com ASP TextStream Object</title>
</head>
<body>
<%
Dim objFSO, objStream,i
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objStream = objFSO.OpenTextFile(Server.MapPath("MyFiles/thaicreate.txt"), 8, True)
objStream.WriteLine("I Love My Live")
Response.write("Writing")
objStream.Close
Set objStream = Nothing
Set objFSO = Nothing
%>
</body>
</html>