If you have your own website, is it true to exchange friendship with others? Each time you add another person with a manual method, have you ever thought about having an automatic friendship link system that automatically registers the website information and produces a friendship link page? If the answers to these two questions are "Yes", then, please come with me, you will soon be able to pay for it.
An automatic friendship link system should have two functions: First, you can collect and store website information; another point is to automatically generate web pages based on stored information. To achieve these two functions, it is clear that only HTML languages is not enough, and must be programmed with CGI or ASP by means of other methods.
At present, foreign service providers offer ready-made CGI programs, with the ability to generate friendship links, which can certainly meet the basic requirements above, but there are at least two disadvantages: one is slow, the CGI program is not very efficient High, coupled to the foreign site, the final speed can be imagined. Another point is lack of flexibility, others' CGI programs are dead, and users do not have much almost room, so they cannot create personality pages.
The use of ASP (Active Server Pages) technology can make up for the above shortcomings. The ASP code not only has sufficient flexibility, but also executes faster than the CGI program, so ASP is a suitable choice for website owners.
First, use ASP to implement an automatic friend love link simple principle.
1. Information collection of friendship sites
In order to collect various information of the friendship site (including name, website name, address, etc.), we only need to use standard HTML FORM technology. That is, a form is placed in the page, where a number of text boxes and a "submit" button are placed, the text box is entered for the user input information, and the form of the form is set to the name of the information processing page, namely the name of the ASP file (in the following example) AutoLink.asp, the method of data transmission is set to POST.
2, the preservation of friendship website information
When the AutoLink.asp file is executed, you first use the REQUEST object's FORM attribute to read each parameter; then create an ADO (Active Data Object) object with the CreateObject method of the Server object, and set the corresponding DNS according to the type, location, name, etc. according to the type of database. After using the OPEN method of the ADO object to establish a database connection; after the connection is established, use a standard SQL statement to add a record to the database (see the following code below the SQL statement). This enables the purpose of saving information.
3, the generation of friendship link page
In order to read the database, you first use the SQL statement to create a recordset RS, then read each field content with the Field property of the RS, and generate a standard HTML statement according to the value of the field.
Second, instance
Here is a specific example.
First, we need to create a database to store all the information about all friendship websites. In this case, we build a simple database AutoLink.mdb with Access, which contains only a table AutoLink, the structure of the table is as follows:
Field Name Data Type Field Length Equivalence Field No Field Description Name Character Type 20 Yes Web Site Name Address Character Type 60 Yes Web Site Address Logoaddress Character Site 60 YES Website Identifier Icon Description Character 120 Yes Website Short Introduction
Next, we need to create two pages: AutoLink.htm and AutoLink.asp.
AutoLink.htm is a standard HTML page that collects information from other websites, which is as follows (for the saving version, the code is saved all modified statements and data integrity check statements):
hEAD>