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 3: Creating the Link for Posting Messages

Creating the Link for Posting Messages

First, create the link to the page for posting messages. Follow these steps:

  1. Open the view_message.php page in Dreamweaver.
  2. Place the cursor before the Logout link but inside the Show If User Is Logged In conditional region border.

    Tip: If you cannot place the cursor exactly, switch to Code view and place the cursor before the <a> tag corresponding to the Logout link. Then switch back to Design view.

  3. Enter the new link’s text, Post message, and add a vertical bar separator after it.
  4. Select the text and click the Folder icon in the Property inspector.
  5. In the dialog box that opens, select the post_message.php file from the site root.
  6. To define the URL parameters to pass, click the Parameters button. In the Parameters dialog box, configure a new parameter (see Figure 1) as follows:
    1. In the Name field enter id_top.

      Passing the topic ID as URL parameter

      Figure 1. Passing the topic ID as URL parameter

    2. In the Value field, enter the following code:
      <?php echo $_GET['id_top'];?>

      This code retrieves the value of the URL parameter passed from the forum home page (when users select a topic).

  7. Click OK twice to close the dialog boxes and add the link.

Because the link has been created before the logout link—but inside the conditional region—it is displayed only when the user is logged in. Preview the forum home page and log in with a valid user name and password, and then click a topic title. You’ll see the link to post a message (see Figure 2).

Link displayed for logged-in users

Figure 2. Link displayed for logged-in users

Protecting the Page from Unauthorized Posts

Next, protect the page against posting messages without authorized access. Although users cannot see the post message link unless they are logged in, typing the page address in the Address bar of the browser will load the page even if users are not logged in. You must restrict access to the page, using the Restrict Access to Page server behavior from ImpAKT:

  1. Open the post_message.php page.
  2. Apply the Restrict Access to Page server behavior from the Server Behaviors tab by selecting Plus (+) > MX Kollection > User Login.
  3. Select the Username and Password option to restrict access based on user name and password only (see Figure 3).
  4. Click OK to apply the server behavior.

    Restricting access to pages

    Figure 3. Restricting access to pages

In the next section, you will create the form that enables users to post messages.

Comments