Use ASP to design a message board (below)

Source: Internet
Author: User
Compile is changed to book. asp. After the form is submitted, it is processed by itself. In this FORM, there are several text input boxes, including name, sex, from, url, email, and comments.
Now, change book.htm to book. asp and add ASP code to the file. As follows: (single quotes indicate the injection of ASP, which is not processed by the compiler.
* Book. asp
<% @ Language = "vbscript" %>
<%
''Indicates the request method. When a client requests a file, such as entering the website address http://active.silversand.net/index.htm, a getrequest is generated. When a form is submitted (the form is set to POST), the POST request method is generated. asp: whether the user opens the page in a browser or submits data for program processing.
If Request. ServerVariables ("REQUEST_METHOD") = "POST" then
'Here, it is determined that the page is transferred by the user to submit the form, so the registration message is processed.
'Create a file component server instance
Set fsFilesys = CreateObject ("Scripting. FileSystemObject ")
'Open the text file server. mappath ("/") is the actual path of the server release Directory, that is, the path c: Inetpubwwwroot, then "/realchat/book/book.txt" is the path based on this path.
Set myText = fsFilesys. OpenTextFile (Server. MapPath ("/") & "/realchat/book/book.txt ")
'Read all the content of the text file and save it in the Temp variable.
Temp = myText. Readall
MyText. Close
'Do you want to add content?
If Request ("task") = "insert" Then
'Get the values of the form items
Tname = request. form ("name ")
Tsex = request. form ("sex ")
Temail = request. form ("email ")
Turl = request. form ("url ")
Tfrom = request. form ("from ")
Tcomments = request. form ("comments ")
Ttime = "# & @" & time
If Len (Tcomments) <2 Then
%>
<Font size = "4" color = "red">
<P align = "center"> Sorry! You have not left a message. <A href = "book. asp"> Return </a> </font> <%
Else
If Lcase (Left (Turl, 7) <> "http: //" Then
Turl = "http: //" & Turl
End if
Turl = Lcase (Turl)
'Recreate the data file and overwrite the original one.
Set myText = fsFilesys. CreateTextFile (Server. MapPath ("/") & "/realchat/book/book.txt ")

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.