Building an Authors Page for a PEAR CMS - HTML Table
(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 logout and the authors link that enables a user to view a list of all authors in the system:
<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>
A link to the admin section of the site is also 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,” then 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 check has been done, the code continues to build a new HTML table that will now host the list of authors that is to be viewed. Also, a new section of PHP code is started. The first part of the code calls the db class which contains the methods and functions that we require to manipulate the MySQL database. The second file to be included in this script is the connx.php file that contains the database connection details:
<!-- InstanceEndEditable --></td>
<td width="95%" valign="top"><!-- InstanceBeginEditable name="EditRegion3" -->
<table width="100%" border="1">
<tr><td></td></tr>
<?php
include 'db.php';
include 'connx.php';
Next: Extracting Author Information >>
More PEAR Articles Articles
More By David Web