Building the View Details Page in a PEAR CMS - Table with Navigation Panel
(Page 3 of 4 )
The next part of the HTML code starts to set up an HTML table that will contain the navigation panel information, such as the link that provides a facility to log out a user:
<table width="100%" border="0" cellspacing="0" class="navbord">
<tr>
<td colspan="2" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td colspan="2" bgcolor="#0066FF" class="section"><strong>Section</strong></td>
</tr>
<tr class="navbord">
<td class="nav"><a href="logout.php">Logout</a> </td>
<td><img src="images/user.gif" width="16" height="16" alt="" /></td>
</tr>
<tr class="navbord">
<td colspan="2" class="nav"><a href="main.php">Home</a></td>
</tr>
<tr class="navbord">
<td colspan="2" class="nav"><a href="authors.php">Authors</a></td>
</tr>
<?php if($_SESSION['level']=="admin"){?>
<tr class="navbord">
<td colspan="2" class="nav"><a href="admin/index.php">Admin</a></td>
</tr>
<?php }?>
</table>
Also, a link to the admin section of the site is provided, but only users with administration level access are allowed to use it. To prevent any unauthorized access to that part of the site, the code checks to see if the session variable called “level” exists, and that the value that is stored in that variable is “admin.” If the value is indeed “admin,” the navigation option is displayed for the user; otherwise it is not shown.
<?php if($_SESSION['level']=="admin"){?>
<tr class="navbord">
<td colspan="2" class="nav"><a href="admin/index.php">Admin</a></td>
</tr>
<?php }?>
Once the admin checks have been done, the code continues to build a new HTML table that will now host the article that is to be viewed:
<table width="100%" border="1">
<tr>
<td colspan="2" class="title"> </td>
</tr>
<?php
First the script calls the db class. This is necessary because we need to use the methods of this class to access and manipulate the database information. Then the connx.php file is included; we need the database connection credentials which are stored there:
include 'db.php';
include 'connx.php';
Next: Displaying the Article >>
More PEAR Articles Articles
More By David Web