< html>
< body>
< form action= "manage.asp" method= "POST" >
< input type= "text" size= "ten" name= "username" >
< input type= "text" size= "ten" Name= "homepage" >
< input type= "text" size= "ten" Name= "Email" >
</form>
</body>
Manage.asp
<%
StrName = Request.Form ("username")
Strhomepage = Request.Form ("homepage")
Stremail = Request.Form ("Email")
' get form information .
Set FSO = Server.CreateObject ("Scripting.FileSystemObject")
' Create an FSO object .
Path = "C:chunfeng/form.txt"
ForReading = 1, ForWriting = 2, ForAppending = 3
Set file = Fso.opentextfile (path, ForAppending, TrUE)
'Open File. OpenTextFilemethod returns aTextStreamObject,This object reveals how to manipulate the contents of a file, and we're still in opentextfiletrue,,,true parameter , system will be wrong
File.write (strName) & vbCrLf
' VB constant vbCrLf produces a newline character .
File.write (strhomepage) & vbCrLf
File.write (stremail) & vbCrLf
' write information to the file .
File.close
Set file = Nothing
Set fso = Nothing
' empty .
Now open form.txt, you can see the following information:
User ' s name
User ' s home page
User ' s Email
1 2< Span Times New Roman '; Mso-hansi-font-family: ' Times mso-bidi-font-size:9.0pt ' is the user homepage, the first 33fso
<%
Set fso = Server.CreateObject ("Scripting.FileSystemObject")
' Create an FSO object .
Path = "C:chunfeng/form.txt"
Set file = Fso.opentextfile (path, 1)
' open the file .
Do until file. AtEndOfStream
' Atendofstream is textstream Attributes of the object , It prompts when to file tail Response.Write ("Name:" & file.) ReadLine & "")
' Readline method reads 1 The content , Until the line break is encountered , then readline Call reads the next line Response.Write ("Home Page:" & file.) ReadLine & "")
Response.Write ("Email:" & file. ReadLine & "< p>")
' parse and format the data line by row .
Loop
' loop through each user's information .
File.close
Set file = Nothing
Set fso = Nothing
%>
It's all done.
If the form.txt itself has errors , such as the fact that each user 's information is only 2 lines instead of 3, the following error message is generated:
Server object error ' ASP 0177:800a003e '
[1]