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:
- Open the view_message.php page in Dreamweaver.
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.
- Enter the new link’s text, Post message, and add a vertical bar separator after it.
- Select the text and click the Folder icon in the Property inspector.
- In the dialog box that opens, select the post_message.php file from the site root.
- 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:
In the Name field enter id_top.
- 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).
- 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).
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:
- Open the post_message.php page.
- Apply the Restrict Access to Page server behavior from the Server Behaviors tab by selecting Plus (+) > MX Kollection > User Login.
- Select the Username and Password option to restrict access based on user name and password only (see Figure 3).
Click OK to apply the server behavior.
In the next section, you will create the form that enables users to post messages.