Showcase and discover digital art at yex

Follow Design Stacks

Subscribe to our free newsletter to get all our latest tutorials and articles delivered directly to your inbox!

Building a Forum with Dreamweaver – Part 4: Building the Reply Form

Building the Reply Form

To build the reply form, follow these steps:

  1. Open the reply_message.php page in Dreamweaver. The page layout is already created.
  2. To allow only logged-in users to access this page, apply a Restrict Access to Page server behavior by selecting the Server Behaviors tab > Plus (+) > MX Kollection > User Login. Configure it as you did on the page for posting message in Part 3.
  3. Before building the form, you must create a filtered recordset that retrieves information about the message being replied to. The recordset is filtered by the message ID passed as a URL parameter from the view_message.php page. You will use this information to display the original message title and provide default values for the reply form.
  4. To create the recordset, click the Plus (+) button of the Bindings Tab and select Recordset (Query). Configure the recordset as shown in Figure 3:

    1. Enter rsOldMessage for the recordset name.
    2. Set the database connection to connForum and select the message_msg table.
    3. In the Filter pop-up menu, select the table’s primary key: id_msg. This must be equal to the id_msg URL parameter.

      Defining the rsOldMessage recordset

      Figure 3. Defining the rsOldMessage recordset

  5. Click OK to create the recordset.
  6. Remove the placeholder text from the main <div> container (the one with the white background) and type the following text:

    Reply to message:

    Next, drag the subject_msg field from the rsOldMessage recordset in the Bindings tab and drop it on the page, right after the text (see Figure 4).

    Displaying the page header

    Figure 4. Displaying the page header

  7. Create a new paragraph after the dynamic text (press the Enter or Return key) and launch the Insert Record Form Wizard. You can access it from the MX Kollection tab of the Insert bar. Because you used the same wizard for the message-posting page, most of the interface fields should already be filled in, thanks to the user interface persistence (provided that this feature is enabled in the InterAKT Control Panel).
  8. The first step is already filled in: the connection, table name, primary key, and redirect page are preserved from the last time you applied the wizard in the post_message.php page. Figure 5 shows what the first step should look like.

    Database information already set up

    Figure 5. Database information already set up

  9. Click Next without changing anything. In Step 2 of the wizard, each field still has its default value and field type configured as in the Post Message page. The following fields are already set up: idtop_msg, idusr_msg, date_msg, subject_msg, content_msg, and subscribe_msg.
  10. Because this is the reply page, you will have to change some settings and add the rest of the fields (see Figure 6):

    1. Set a default value for the message subject. It will display the original message subject, preceded by Re:, to indicate that the current message is a reply.
    2. Click the InterAKT Dynamic Data icon (the blue lightning bolt next to the Default value text field) to select the subject_msg column from the rsOldMessage recordset.

      Setting the subject default value

      Figure 6. Setting the subject default value

    3. After the dynamic value has been added to the Default Value text box, simply enter Re: before the automatically generated mark-up code (see Figure 7).

      Adding static text to the default value

      Figure 7. Adding static text to the default value

    4. You need to add two more fields to the insert transaction: idmsg_msg and id_init_msg. To add them, click the Plus (+) button on top of the grid and select the fields from the list (see Figure 8).

      Adding fields to the transaction

      Figure 8. Adding fields to the transaction

    5. For the idmsg_msg field, select Text in the Display As pop-up menu and use the id_msg field from the rsOldMessage recordset as its default value (again, click the blue lightning bolt icon to select the default value).
    6. For the id_init_msg field, select Text in the Display As pop-up menu and use the id_init_msg field from the rsOldMessage recordset as its default value (using the blue lightning bolt).

      Figure 9 shows what Step 2 of the Insert Record Form Wizard should look like after all options have been set up.

      Configured reply form fields

      Figure 9. Configured reply form fields

  11. In Step 3 of the wizard, apply validation rules on the transaction fields. Make all fields required, except the Subscribe check box. Also, all foreign keys (idtop_msg, idusr_msg, idmsg_msg, and id_init_msg) must be positive integers. Finally, the date field should have the Datetime format. Figure 10 shows the settings of Step 3.

    Defining the validation rules for the reply form

    Figure 10. Defining the validation rules for the reply form

  12. Click Finish to close the wizard and apply the changes.
  13. After the form is added to the page, remove the rows containing the Date, Idtop, Idusr, Idmsg, and Id_init fields. These will remain in the insert transaction but should not be visible to the user. Figure 11 shows what the form should look like.

    Design view of the reply form

    Figure 11. Design view of the reply form

  14. Rename the Insert record button; it should be labeled Reply.

The page for replying to messages is complete, and you can save it and upload it to the server. You cannot access this page directly unless you are logged in (because of the Restrict Access to Page server behavior). Figure 12 shows an example of a reply to an existing message.

Replying to a message

Figure 12. Replying to a message

With this page, the basic forum application is complete. Users can register accounts and view, post, and reply to messages.

In the next section you will enhance the forum application by keeping users informed about replies to their messages.