PEAR Articles

  Home arrow PEAR Articles arrow Deleting Authors from a PEAR Content M...
PEAR ARTICLES

Deleting Authors from a PEAR Content Management System
By: David Web
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-12-03

    Table of Contents:
  • Deleting Authors from a PEAR Content Management System
  • Code Explained
  • Extracting Database Information
  • Adding Authors

  •  
     

    SEARCH CODEWALKERS

    Deleting Authors from a PEAR Content Management System


    (Page 1 of 4 )

    Sometimes, for whatever reason, if you have a content management system, you may need to make some major deletions. In this twelfth part of our ongoing series on building a content management system in PEAR, we will take a close look at the code necessary to allow us to delete entire authors from the system, along with their articles. Keep reading; the magic starts with the listauth page.

    This page is responsible for listing the names of all the authors in the database. Not only does it list the names of the authors, but it also provides an option to remove an author from the system. This is handy for those times when an author is no longer using the content management system or if you simply want to lighten the load on the database server. We all know that if a database contains too much information that it slows down considerably. The purpose of the admin section is basically to maintain the CMS, by for example getting rid of redundant data.

    The listauth.php script

    The listauth page is responsible for listing all of the authors for the users, almost as in the CMS section of the application. The difference is that when the author names are listed here, it is for maintenance purposes. The list of names also have another listing that links the author ID to the delete script. By clicking on the delete link, the user will automatically delete the selected author and all related articles from the CMS system. Below is the code that does the job:

    <?

    session_start();

    if($_SESSION['level']!=="admin"){

    //redirect to login page

    header(location:"login.php");

    }

    ?>

    <!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" --> <table width="100%" border="1">

    <?

    include 'db.php';

    include 'connx.php';

    $sql = "SELECT * FROM authors";

    $res = $db->query($sql);

    //if($num>0){

    while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {

    ?>

     

    <tr>

    <td width="25%" class="auth"><a href="authart.php?<?=$row->aid?>" class="auth">$row->name</a></td>

    <td width="75%" class="auth"><a href="delete.php?<?=$row->aid?>">Delete</a> </td>

    </tr>

    <? }

    }else{

    ?>

     

    <tr>

    <td colspan="3" class="maintxt"><p class="auth">No authors found</p></td>

    </tr>

    <? } ?>

    </table>

    <!-- InstanceEndEditable --></td>

    </tr>

     

    <tr class="copy">

    <td colspan="2">&copy;2008</td>

    </tr>

    </table>

    </body>

    <!-- InstanceEnd --></html>

    More PEAR Articles Articles
    More By David Web

    blog comments powered by Disqus

    PEAR ARTICLES ARTICLES

    - Installing PEAR
    - PEAR: an Introduction
    - Managing robots.txt using PHP: Generating Dy...
    - Deleting Authors from a PEAR Content Managem...
    - PEAR CMS: Index and Delete Scripts
    - Listing Articles for a PEAR Content Manageme...
    - Building an Authors Page for a PEAR CMS
    - Building the View Details Page in a PEAR CMS
    - Creating the Main Pages of a PEAR CMS
    - Completing the Login Script for a PEAR CMS
    - User Authentication for a PEAR CMS
    - A PEAR CMS: Examining the Code
    - Building a Content Management System with PE...
    - Installing a PEAR Package
    - My PEAR: The Beginning

    Developer Shed Affiliates

     



    © 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap