Deleting Authors from a PEAR Content Management System - Code Explained
(Page 2 of 4 )
Here’s what that code produces:
The code below checks to see if the currently logged-on user has admin clearance, by using PHP session variables. Because in this portion of the application it is so easy to make mistakes, since you are deleting articles and authors, it is important that only users who have admin clearance access this area. The code below clears a user if the level called by the session variable contains a value called admin. If it does, the user is cleared to be in this area; otherwise the user is redirected to the login page:
<?
session_start();
if($_SESSION['level']!=="admin"){
//redirect to login page
header(location:"login.php");
}
?>
The HTML portion of the page is responsible for the overall look of the page. It also contains the template, styles and other elements such as HTML tables. Another element that this particular HTML code hosts is the navigation panel, which has four links to other pages in the admin area:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/main.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<link href="../Templates/pear.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%" border="0" class="bord">
<tr class="header1">
<td colspan="2"><div align="center">Content Management System </div></td>
</tr>
<tr>
<td width="5%" valign="top"><!-- InstanceBeginEditable name="EditRegion4" --><table width="100%" border="1">
<tr>
<td colspan="2" bgcolor="#0066FF"><strong>Section</strong></td>
</tr>
<tr>
<td class="nav">Logout </td>
<td><img name="" src="" width="32" height="32" alt="" /></td>
</tr>
<tr>
<td colspan="2" class="nav"><a href="index.php">Home</a></td>
</tr>
<tr>
<td colspan="2" class="nav">List Authors </td>
</tr>
<tr>
<td colspan="2" class="nav"><a href="add_auth.php">Add Authors</a></td>
</tr>
<tr>
<td colspan="2" class="nav"><a href="delete.php">Delete articles </a></td>
</tr>
</table>
<!-- InstanceEndEditable --></td>
<td width="95%" valign="top"><!-- InstanceBeginEditable name="EditRegion3" -->
Next: Extracting Database Information >>
More PEAR Articles Articles
More By David Web