Dreamweaver MX creates our guestbook (1)
Author:Eve Cole
Update Time:2009-05-31 21:07:19
Hello everyone, we meet again. :) In the previous chapters, we talked about how to use the server behavior of DW MX to operate the database and generate dynamic pages, but don't you think it's a bit confusing and not easy to understand? Yes, what we talked about earlier are individual server behaviors, and they seem to have no connection. In this chapter, we will learn how to flexibly apply the server behavior of DW MX - to create our guestbook! (Yes, it is a guestbook, which will use most of the server behaviors without writing a line of code.)
Do some preparation work first, create a few new pages and name them:
index.asp: Guestbook home page, used to display messages, etc.
new.asp: Post a new message.
rep.asp: The page used by the webmaster to reply to messages.
edit.asp: A page for editing some unhealthy message content.
del.asp: Same as above, but the method is more ruthless, delete it directly. :)
login.asp: Only the webmaster has the authority to reply, edit, delete and other operations mentioned above. The webmaster can log in and manage the guestbook through this page.
sorry.asp: The page returned when the login is incorrect.
As shown in Figure (7-1).
7-1
In terms of database, we need to use two tables, as shown in Figure (7-2). The table admin is used to store the name and password of the super user, and the table f_bbs stores the posting information. We will explain it in detail later.
7-2
Create two new fields in the admin table, named f_name and f_password, and set the data type to text respectively, as shown in Figure (7-3).
7-3
Table b_bbs is a bit troublesome, but don’t be afraid, let’s do it step by step, first look at the picture (7-4).
7-4
The field ID is the key field of the message content because it has many functions. Set its data type to automatic numbering and set it as the primary key, that is, select it and click on the red circle in Figure (7-4) button.
f_name is the name of the user who left the message, which is very simple.
f_content stores the message content. Since the text data type can only store up to 255 characters, which is a bit less for our message content, we need to set it as a note here because the data type of the note can store up to 65,535 characters. characters, which is completely enough. :)
f_oicq is the OICQ number of the message user, set with the same user name.
f_email is the email address of the user who left the message, and is set to the same user name.
f_homepage is the homepage address of the user, set with the same user name.
f_time is the time when the message was submitted. Please note here that the data type must be changed to date/time and a default value must be set. As shown in Figure (7-5). This now() is a VBA built-in function. Its function is that if the value of the field is not specified when submitting a message, the system will fill the field with the current date and time.
f_repcontent is the content of the webmaster's reply, which is the same as the content of the message. However, it should be noted that a default value must also be added, as shown in Figure (7-6). Its function is to display "No reply yet" if there is no reply to the current message content. Pay attention to the two double quotation marks. They must be entered in English, such as "". If "" is entered in Chinese, an error will be reported.
7-5
7-6
After preparing the database, it’s our protagonist’s turn, index.asp. This page is used to display messages and some functional connections. Let’s first take a look at its general appearance, as shown in Figure (7-7). At the same time, remember to create a record set and name it guestbook.
7-7
I am just here for the sake of convenience, so I don’t use any pictures. The approximate appearance is as above. The most important thing is to display the name of the person who left the message, the message content and the webmaster's reply. The following "no reply" is used to ensure that it is displayed when there is no message content. This also ensures that there will be no errors. Then some attentive readers may ask, why haven't I seen the OICQ number and homepage address I created in the database above? Oh. . Don't worry, of course you need to use these, see Figure (7-8), this is a basically formed look.
7-8
How about, please show the OICQ, email, homepage, and publishing time. It seems quite troublesome. Don't be afraid, it's actually very simple, just a few small server actions, let's go! ! Let's take it step by step.
Hello everyone, we meet again. :) In the previous chapters, we talked about how to use the server behavior of DW MX to operate the database and generate dynamic pages, but don't you think it's a bit confusing and not easy to understand? Yes, what we talked about earlier are individual server behaviors, and they seem to have no connection. In this chapter, we will learn how to flexibly apply the server behavior of DW MX - to create our guestbook! (Yes, it is a guestbook, which will use most of the server behaviors without writing a line of code.)
Do some preparation work first, create a few new pages and name them:
index.asp: Guestbook home page, used to display messages, etc.
new.asp: Post a new message.
rep.asp: The page used by the webmaster to reply to messages.
edit.asp: A page for editing some unhealthy message content.
del.asp: Same as above, but the method is more ruthless, delete it directly. :)
login.asp: Only the webmaster has the authority to reply, edit, delete and other operations mentioned above. The webmaster can log in and manage the guestbook through this page.
sorry.asp: The page returned when the login is incorrect.
As shown in Figure (7-1).
7-1
In terms of database, we need to use two tables, as shown in Figure (7-2). The table admin is used to store the name and password of the super user, and the table f_bbs stores the posting information. We will explain it in detail later.
7-2
Create two new fields in the admin table, named f_name and f_password, and set the data type to text respectively, as shown in Figure (7-3).
7-3
Table b_bbs is a bit troublesome, but don’t be afraid, let’s do it step by step, first look at the picture (7-4).
7-4
The field ID is the key field of the message content because it has many functions. Set its data type to automatic numbering and set it as the primary key, that is, select it and click on the red circle in Figure (7-4) button.
f_name is the name of the user who left the message, which is very simple.
f_content stores the message content. Since the text data type can only store up to 255 characters, which is a bit less for our message content, we need to set it as a note here because the data type of the note can store up to 65,535 characters. characters, which is completely enough. :)
f_oicq is the OICQ number of the message user, set with the same user name.
f_email is the email address of the user who left the message, and is set to the same user name.
f_homepage is the homepage address of the user, set with the same user name.
f_time is the time when the message was submitted. Please note here that the data type must be changed to date/time and a default value must be set. As shown in Figure (7-5). This now() is a VBA built-in function. Its function is that if the value of the field is not specified when submitting a message, the system will fill the field with the current date and time.
f_repcontent is the content of the webmaster's reply, which is the same as the content of the message. However, it should be noted that a default value must also be added, as shown in Figure (7-6). Its function is to display "No reply yet" if there is no reply to the current message content. Pay attention to the two double quotation marks. They must be entered in English, such as "". If "" is entered in Chinese, an error will be reported.
7-5
7-6
After preparing the database, it’s our protagonist’s turn, index.asp. This page is used to display messages and some functional connections. Let’s first take a look at its general appearance, as shown in Figure (7-7). At the same time, remember to create a record set and name it guestbook.
7-7
I am just here for the sake of convenience, so I don’t use any pictures. The approximate appearance is as above. The most important thing is to display the name of the person who left the message, the message content and the webmaster's reply. The following "no reply" is used to ensure that it is displayed when there is no message content. This also ensures that there will be no errors. Then some attentive readers may ask, why haven't I seen the OICQ number and homepage address I created in the database above? Oh. . Don't worry, of course you need to use these, see Figure (7-8), this is a basically formed look.
7-8
How about, please show the OICQ, email, homepage, and publishing time. It seems quite troublesome. Don't be afraid, it's actually very simple, just a few small server actions, let's go! ! Let's take it step by step.