< html>
< body>
< form action="" method="post">
< input type="text" size="10" name="username">
< input type="text" size="10" name="homepage">
< input type="text" size="10" name="Email">
< /form>
< /body>
< /html>
< %
strName = ("username")
strHomePage = ("homepage")
strEmail = ("Email")
' Get form information.
Set fso = ("")
' createfsoObject.
path = "c:chunfeng/"
ForReading = 1, ForWriting = 2, ForAppending = 3
set file = (path, ForAppending, trUE)
' Open the file. OpenTextFileThe method will return aTextStreamObject, This object reveals how to manipulate file content,Such as writing, reading, skipping a line.Also we are still hereOpentextFileThe command parameters are defined intrUE,Meaning if the file does not exist,Just create it.Because if the file does not exist,And no definitiontrUEparameter,The system will have an error.
(strName) & vbcrlf
' VBconstantvbcrlfGenerate a newline.
(strHomePage) & vbcrlf
(strEmail) & vbcrlf
' Write information to the file.
set file = nothing
set fso = nothing
' Clear.
Open now, you can see the following information:
User's name
User's home page
User's email
We then separate the information of each visitor from the record.Because it does not have a database-like column, you need to find a way to read it from the file you just recorded. In the created file,1The line is the username,2The row is the user's homepage,3The row is the user's email address, and the information of other users is arranged in this way, that is, each3The row contains a user information. In this way, we can reuse itFSOCome to read:
< %
set fso = ("")
' createfsoObject.
path = "c:chunfeng/"
set file = (path, 1)
' Open the file.
do until
' AtEndOfStreamyesTextStreamObject properties,It prompts when to reach the end of the file.
("Name: " & & " ")
' ReadLineMethod reading1Line content,Until a newline character is encountered,The followingReadLineCall to read the next line.
("Home Page: " & & " ")
("Email: " & & "< p>")
' Analyze and format data line by line.
loop
' List each user's information in a loop.
set file = nothing
set fso = nothing
%>
All are done.
ifThere is an error in the data itself, such as only the information of each user is2OK instead of3OK, then the following error message will be generated:
Server object error 'ASP 0177 : 800a003e'
[1]