PEAR Articles

  Home arrow PEAR Articles arrow Page 2 - Building the View Details Page in a PE...
PEAR ARTICLES

Building the View Details Page in a PEAR CMS
By: David Web
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-11-05

    Table of Contents:
  • Building the View Details Page in a PEAR CMS
  • Code Explained
  • Table with Navigation Panel
  • Displaying the Article

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Building the View Details Page in a PEAR CMS - Code Explained


    (Page 2 of 4 )


    The first part of this script tries to determine if the currently logged-on user actually has the right to be viewing this script. It does this by starting a session, which will have two session variables available. The code will use one of these variables to check if a user should view the page.

    This is how it does this: first, it calls the session_start() function to open up a session. This is because this piece of code uses the application-wide session variable called ‘author_name’ to determine if it should redirect the user to the login page or not. It tests the variable by checking to see if it is set using the appropriately named isset() function of PHP, which evaluates the parameter that it is passed to see if it contains any values.

    If it does contain a value, then the user will be allowed to use the page. If it does not contain any values, then the user is redirected to the login page, because the program logically assumes that the user is not authenticated:

    <?php

    session_start();

    if(!isset($_SESSION['author_name'])){

    //redirect to login page

    header("location:login.php");

    }


    ?>


    The next part of the page starts to build the HTML portion of the script. The HTML code will also include a table that will eventually host the dynamic content that we want to display:


    <!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" -->

    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


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