PEAR Articles
  Home arrow PEAR Articles arrow Page 4 - User Authentication for a PEAR CMS
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

User Authentication for a PEAR CMS
By: David Web
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-10-15

    Table of Contents:
  • User Authentication for a PEAR CMS
  • Code Explained
  • String or Numeric
  • Granting Access to the CMS

  • 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


    User Authentication for a PEAR CMS - Granting Access to the CMS


    (Page 4 of 4 )

    If there was no error, we continue to check whether any records have been returned, by testing the $res variable which will have the result of the query stored in it. If any records have been found, it means that the user does exist in the database, therefore we have to grant the user access to the CMS.

    The next step that we take is to retrieve some user data. To do this we run a while loop to retrieve the information stored in the result variable. Also notice that we use DB's fetchrow() function to get the user's information. As a result, all data about the user is now stored in the $row variable. For the time being we only need to know the user's access level, so we extract it from the results:

    if($res){

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

    $level=$row->level;

    }//end while loop

    //******************************************Set up Session vars

    We need two pieces of information to ensure that the CMS is accessed only by users who are known by the system, namely the username and access level. This information will be used to evaluate whether a user should be granted access to any of the scripts that make up the CMS. As a way of making this information available to all the scripts, we put them in session variables and then redirect the user to the main page of the CMS:

    //user exists, setup session vars

    $_SESSION['author_name'] = $username;

    $_SESSION['level']=$level;

    header("location:main.php");

    }//end res check

    If the result variable ($res) does not contain any records, an error message is added:  

    else{

    //user does not exist

    $error .= "Your login details did not match";

    }

    }//end err check

    In the next article we will discuss the HTML form that is responsible for collecting the information that we require from the user. We will also look at the last section of the user management process that deals with logging users out of the system.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    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 6 Hosted by Hostway
    Stay green...Green IT