Researry address: http://www.5xsoft.com/data/200110/2508070601.htm
Preface: Now there is a situation everywhere, but I don't know if you have encountered this situation: I am looking for what I want in the messy discussion information. It is a very expensive thing. Later, you will I don't want to see what forum. So can we increase audit functions on the content of our website forum? That is, all netizens sent to the forum, and it is not immediately displayed. After the webmaster or moderator review, it is considered valuable. It is necessary to recommend it to other netizens, and published. Otherwise, it will be deleted, so exclusted to waste space, it is a bit like the meaning of the essence, so your forum can be provided to clearly beneficial content than a general forum. Put it on your website, you should attract more users to visit. This idea can of course be realized, let me briefly introduce how to make it. Note: Since this article applies to readers with a certain understanding of the Access database, HTML, ASP.
I. Forum structure analysis, through the above functional demand analysis, we can divide the forum into four parts: (1) Netizen registration and management module: Because the webmaster or moderator, you must be able to Perform authentication. The function of this module is to manage the registered netizen and provide relevant queries. For example, query all published articles of the author of the author, query the top ten netizens who currently publish the most articles, and so on. If your forum is not very big, this module can omit the function with only the moderator authentication, and remove the part about registration, query. (2) Article display module: Show all version of the primary audina, feel a recommended article. (3) Post article module: Provide a place where the registered netizen provides the publication, and release the master review. (4) Article Review Module: The moderator is handled for all the nets published but unreviewed articles, which have been decided to be published or deleted. After understanding the specific functional requirements, you can design it by the module's start forum. Of course, these modules are only functional to the forum structure, which is actually unable to independently design them. For this smaller applications, there is no need to perform a complete modular design, which is more simple to write directly to the program code under good plan. There are general two ways to implement for the forum: file or database. Relatively, the database is simple and efficient, and it is possible to better control the forum, and some verification and protection can be provided. I am using the Access database here, and Access should be competent for general small and medium-sized applications.
From the above analysis, you can know that there should be four tables, below I give the structure of each table. (1) the author list (used to store the author message): ID: Text type, required. It is a netizen code. Password: Text type, required. Nickname: Text type, mustal. Email: Text type, required. Position: Digital type, required. -1 represents ordinary netizens, 0 represents the webmaster. Digital representative version of greater than 0, and the number is the ID of a plate in the table table, indicating that the board of the board. Number of articles: Digital type, required. The total number of articles published by netizens. Name: Text type, optional. Gender: Text type, optional. Phone: Text type, optional. (2) Content table (used to store specific articles content and related messages): ID: Auto number and set index to speed up the speed of search. Plate ID: Digital Type, from the list of board, indicating that the article is a board. Theme ID: Digital Type, from the topic table, indicating the topic of the article. Author ID: Text type, from the author table, indicating the author of the article. Date: Date / Time Type, preset initial value is a function now (), the system will automatically take the system current time to its value when adding this field. Title: Text Type. The title of the article. Published: Yes / No Type, indicates that the article has passed the review, you can publish it; "No" means that the article is still looking for. Recommendation: Digital Type, Recommendation of Articles. Content: Note type, specific content of the article. Clicks: Digital Type, Clicking on Articles. (3) List of boards (used to store messages related to the board): ID: Auto number, the same, also set indexing. Name: Text type, the name of the board. Plate, text type, ID. Numms: Digital Types, the number of topics included in the board. (4) Topic table (to store messages related to topics): ID: Auto number and set indexing. Title: Text type, indicating the topic name. Watch: Digital Type, from the list of board, indicating the board to which the theme belongs. Number of articles: Digital type, number of articles included in the subject. All the table is designed, but the database is not finished, so we also need to establish an intervivinary relationship, so that the database can perform some relevant inspections, avoid information errors. Another benefit of establishing an inter-mean relationship is that it can easily establish a complex Join inquiry. Usually, when we operate in the ASP, it is used to execute the query generated when using it, and then interpret it by the delivery to the database. And here we need to store inquiry. Compared with the execution, the pre-depreciation has more advantages. It is saved in the database, independent of the ASP program code, making him easier to establish and modify, and the query is more efficient, faster, you can debug it in the ASP page, can avoid many problems. Moreover, the ASP program code that stores queries is easier to read and modified.
It may be very annoying, especially those commaings,, especially those commaings, numerals, one thing that is not careful. After using the storage query, you don't have to take care of these problems. Of course, there are some places to pay attention to in the pre-depreciation process, and I will explain it in detail later. Establishing a pre-depression in Access is a very easy thing, I will not say more. I only give the SQL statement program code for each query. I put all the queries you want to use as the pre-deposit program in the database, and some of the following: (1) Press the ID query article: SELECT topic table. Title AS theme name, list. Name AS Code name, Content table. * From theme table inner Join (Content Table Inner Join Watch List ON Content Table. Watch ID = List. Id) ON Topic Table .ID = Content Table. Theme Idwhere ((Content Table .id) = [ArticleID] ]); (2) Primitive password query: SELECT board list. Board owner, the author Table. Password from the author Table Inner Join board list ON author Table. ID = List of boards. Planner WHERE ((((List of board .id) = [id]; (3) Search for authors:. SELECT * FROM tABLE authors of table WHERE (((author table .ID) = [id])); (4) published an article listing: SELECT [table of contents] [ID. ], [Content Table], [Content Table]. [Author ID] AS Author, [Content Table]. [Date], [Content Table]. [Recommendation], [Content Table]. [Clicks ] AS Click on the number .FROM Content Table Where (([Content Table]. [Topic ID]) = [Topicindex]) And ([Content Table]. [Published]) = true)); No Article list: SELECT Content table. ID AS article ID, theme table. ID AS topic ID, theme table. Title AS topic, content table. Title AS title, content table. Author ID AS author, content table. Date AS date from theme table Inner Join content Table ON Topic Table. Id = Content Table. Topic IDwhere ((Content Table. Published) = false) and ((Content Table. Watch ID) = [BoardID])); (5) Topic List: SELECT Topic Table. * List of boards. Name AS Plate name from FROM List Inner Join Theme table on the board list. Id = Table. Wanches WHERE (((Top Table. Watch) = [BoardIndex])); there are some queries because most classs I will not list it. In the above query statement, I can see something surrounded by "[" and "]", that is, the query parameters. Need to give parameter values when executed, then Bring the parameter value into the query statement to be executed. Also, what is important is: When establishing those INNER JOIN queries, it is necessary to add the intervals to the design view, otherwise it is not possible to automatically generate InN. Er Join query statement. At this point, the database is designed, and the future work is ASP.
Second, build
1. Build a master form to give a form, allowing users to enter registration messages, these are HTML content, and put it on one side, let's take a closer look at the ASP script that specifically implemented registered. (1) Change the single quotes in the information to two single quotes, and add single quotation markstr = "" "and" End Function Note: "End Function Note: This is a custom function that converts single quotes () in user input into two single quotes (). In ASP, the string is surrounded by double quotes, and the above "" "means that only one single quotes are character. The reason why a single quotation is replaced with two single quotes, because in the SQL statement, use single quotes to represent variables. In order not to confuse, you should use both single quotes in the string to represent two single quotes. All user inputs are embedded as variables into the SQL statement, so this function is essential. (2) Storage Preparation ID = Request ("ID") Password = Request ("Password") Nickname = Request ("Nickname") Email = Request ("email") SEX = Request ("sex") Note: Put from The content in the user enters the form is saved in the variable, which is not necessary, but it is easier to read and write. if Request ("Name") = "" "" "" "" ") =" "" ") =" "" "" "" "
Because these contents do not have to be filled, in order to prevent the user from entering anything, but cause an error on the database operation, it is necessary to replace the field without filling the field. (3) Establish a connection set conn = server.createObject ("AdoDb.Connection") Conn.open "Driver = {Microsoft AccessDriver (* .mdb)}; dbq =" & Server.mAppath ("bbssystem.mdb")
Note: This section is to establish a database connection, the name of the database is bbssystem.mdb, the only thing to note in this paragraph is the application of the server.mappath function. In general, anywhere involving a specific directory, do not use the directory name directly, and replace it with the server.mappath function. Good use of functions such as Server.MAppath and Request.ServerVariables () to make your web application have better portability. SET cmd = server.createObject ("adodb.command")
(4) Query if the author has set cmd.activeconnection = conncmd.commandtext = "Query author" Redim param (0) Statement parameter array param (0) = cstr (ID) CINT cannot ignore SET RS = cmd.execute (, Param Note: This is used to perform pre-depreciation procedures. There are many ways to perform queries in ADO, but you can only use Command objects for the pre-depreciation. First, establish a Command object called CMD, then set the CONN connection object to the ActiveConnection property of the CMD object, set the query name "Query the author" to be executed to the CommandText property, then assign a value for the query parameter. We declare a parameter array param (0) because there is only one parameter in the "Query Author" query, so an array has only one component. In general, there are several parameters in the query, it is necessary to declare an array of parameters in the number of corresponding components. And the order in which the parameters appears is the order of the components in the array. In the process of using the parameter query, it is important to note that the type of parameters must be strictly matched, and if this will be wrong, the above CSTR () type conversion function is indispensable. If not (rs.eof or rs.bof) ThenRESPONSE.WRITE "error, the ID number you entered is already occupied, please try again!" ElseSQL = "Insert Into author Table (ID, nickname, email, password, Name, School, Series, Gender, Phone) Values ("SQL = SQL & SQLSTR (ID) &", "SQL = SQL & SQLSTR (Nickname) &", "SQL = SQL & SQLSTR (Email) &", " SQL = SQL & SQLSTR (PASSWORD) & "," SQL = SQL & SQLSTR (Name) & ", &", "SQL = SQL & SQLSTR (SEX) &", "SQL = SQL & SQLSTR (Phone) &") Conn.execute SQL
Insert the data into the database using a SQL INSERT statement. In fact, this inquiry can also be made in the database. I stole my little lazy :-) However, it can also see the benefits of the pre-depreciation program, and it is too much trouble when the query is written.
2. Build a article shows that the module says that a specific article is subrouting under the board and subject. So the display of the article is also available after the list of lists and main lists can be obtained, and the list of articles under specific topics can be obtained. (1) Display page of the board: