PEAR Articles
  Home arrow PEAR Articles arrow PEAR CMS: Index and Delete Scripts
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PEAR ARTICLES

PEAR CMS: Index and Delete Scripts
By: David Web
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 2
    2008-11-26

    Table of Contents:
  • PEAR CMS: Index and Delete Scripts
  • Delete Script continued
  • The index.php script
  • The code explained

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    PEAR CMS: Index and Delete Scripts


    (Page 1 of 4 )

    This article will look at the index and delete scripts. The index page for the admin section is the first page that you will see when entering the admin portion of the site. It displays a welcome note. There are also a lot more links on the navigation panel of the admin section. This is the eleventh part of a twelve-part series on building a content management system with PEAR, so without any further ado, let’s take a look at the delete script.

    The Delete script

    The delete script is used to get rid of any data that you don’t want in the CMS. It removes articles and authors as needed. It has the following code:


    <?php

    //set error variables

    $err=false;

    //check if author id has been sent

    if(isset($_GET['aid'])){

    //check if it is numeric

    if(is_numeric($_GET['aid'])){


    //first delete author

    $sql="DELETE FROM authors WHERE aid=$_GET['aid']";

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

    if(!$delauth){

    $err=true

    }

    }


    //Then delete all articles written by author

    $sql="DELETE * FROM stories WHERE author=$_GET['aid']";

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

    if(!$delarts){

    $err=true

    }

    }


    if(!$err){

    //get back to the list authors page

    header(location:"listauth.php");

    }

    }else{

    echo The following error(s) occurred:<br>

    echo $errmsg.”<br>”;

    }


    ?>


    The delete script starts by declaring some Boolean variables that we will use to detect errors in the execution of the code. The variables are $errmsg and $err. The $err variable is of type Boolean; it can only have one of two values: TRUE or FALSE.

    The $errmsg variable is of type string and will contain different types of messages based on where in the code it is. We set it to false at the beginning, because it has not been used yet. This script is called by the listauth.php script which sends an article ID to the delete script when a user clicks on the delete link.


    <?php

    //set error variables

    $err=false;

    $errmsg=’’;

    More PEAR Articles Articles
    More By David Web


     

    PEAR ARTICLES ARTICLES

    - 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
    - Using XML_RPC2 with PEAR
    - Using Web Service APIs (Amazon and Yahoo!) w...
    - Database Abstraction with MDB2 from PEAR





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT