Create a guestbook with DreamweaverMX (4)
Author:Eve Cole
Update Time:2009-05-31 21:07:04
What we need to do now is to add a message page, new.asp. The principle is to add data to the database we designed earlier, and we will not go into details here, as shown in Figure (7-36).
7-36
Remember to define it and go to the index.asp homepage after submitting the data. In order to prevent it from going wrong, we have to use a behavior on it, but this time don't use the server behavior, just use the behavior that comes with DW MX. After selecting the form form, Design-->Behaviors-->Validate Form (Design-->Behavior-->Validate Form), as shown in Figure (7-37).
7-37
Remember to check the required fields for f_name and f_content, change the acceptable type of f_oicq to Number, and change the acceptable type of f_email to Email Address.
As for edit.asp (edit page), rep.asp (reply page) and del.asp (delete page), they simply accept the value we passed earlier and display the corresponding data, and then use the Updata Recordt and Delete Record server behaviors. We will not go into detail here. The effects are shown in Figures (7-38, 7-39, 7-40).
7-38
Here is the edit.asp page. When creating a record set, it is the same as before, but remember to apply the Move To Specific Record server behavior so that the corresponding record set can be found. The problem of making the above table is the same as that of index.asp, except that the displayed user name, user message and webmaster reply must be changed into a text box, and the corresponding database fields must be dragged into the text box, and finally the Updata Recordt server must be used Behavior, then define the updated data and return to the index.asp page. Another thing to note here is that the entire large table must be placed in the form to be effective.
7-39
This is the del.asp page. We also need to create a form, but there is no need to change the name, etc. into text boxes, because we are only deleting data. What is important is the Move To Specific Record server line and Delete Record server behavior. Finally, define the transfer after deletion. Go to the index.asp page.
7-40
This is the rep.asp page. This page is similar to the edit.asp page above. It also uses the Updata Recordt server behavior, but the difference is that it only updates the content of one field. As above, you need to use the Move To Specific Record server behavior to change the site. Long replies changed to text boxes so superusers can type.
OK, it’s just a little bit closer, work hard and try harder! ! !
We have to consider a question here, how to let super users with administrative rights manage messages? That is, you can edit, delete, reply, etc. Login is used here. This is a server behavior that we have not touched before. Log In User server behavior. Again, it's simple and easy to learn. :)
Open the login.asp page, create forms, tables, and text boxes, and name the upper text box f_name, the lower one f_password, and change its type to password, as shown in Figure (7-41) ) shown.
7-41
After doing all this, use Application-->User Authentication-->Log In User (Application-->User Authentication-->User login), as shown in Figure (7-42).
7-42
After clicking, a dialog box as shown in Figure (7-43) will appear.
7-43
Get Input Form Form: Select which form to accept submission from this drop-down list. We only have one form here, so there is no need to choose.
Username Field: Select the text box corresponding to the username here. We just defined the user name text box as f_name, so f_name is also selected here.
Password Field: Select the text box corresponding to the user password here, same as above.
Validate Using Connection: Choose which database connection to use here.
Table: Which table in the database to use. It should be noted here that we need to use the admin table here, although we have always used the f_bbs table before.
Username Column: Select the field corresponding to the user name. Here, select the f_name field in the database.
Password Column: Select the field corresponding to the user password, same as above.
If Login Succeeds, Go To: If it passes the verification, which page to go to, here we define the return homepage index.asp.
If Login Fails, Go To: If the page does not pass verification, here we define which page to return to sorry.asp.
Restrict Access Based On: Because we need to restrict access to some pages, such as editing and deletion, we need to use this. Select Username and Password in the latter type, that is, username and password.
Click OK to complete the settings for this page.
Now we have to look back. Our edit, asp, del.asp, and rep.asp cannot be accessed casually by others. Here we need to use the server behavior of page protection. Application-->Server Behaviors-->User Authentication-->Restrict Access To Pags (Application-->Server Behavior-->User Authentication-->Page Data Protection), as shown in Figure (7-45).
7-45
After clicking, a dialog box as shown in Figure (7-46) appears.
7-46
Restrict Ased On: The type of page protection. Here we choose username and password.
If Access Denied, Go To: If there is illegal access, which page to go to. Here we choose to let illegal access go to login.asp (login page).
The pages that need to be protected include edit.asp, del.asp, rep, and asp. The settings for each page are the same, so remember to set them.
As for the final sorry.asp page, it is a simple page, as shown in Figure (7-47). Add a link to this "here" to the login.asp page.
7-47
It’s over! Oh, I mean it's finally done. :)