Why do some guest books do not need a database? _ Programming 10000 Q

Source: Internet
Author: User
Tags readline

< 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]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.