PHP
  Home arrow PHP arrow Page 6 - User Authentication With patUser (part...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
VPS Hosting 
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? 
PHP

User Authentication With patUser (part 2)
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 7
    2003-05-01

    Table of Contents:
  • User Authentication With patUser (part 2)
  • Meeting The Family
  • Asking For More
  • Drilling Deeper
  • All For One, And One For All
  • Accounting For Change
  • California Calling
  • Making New Friends
  • A Fast Edit
  • Here Today, Gone Tomorrow
  • Connecting The Dots
  • A Well-Formed Plan
  • Slice And Dice

  • 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 With patUser (part 2) - Accounting For Change


    (Page 6 of 13 )

    The default patUser-supplied database schema for the "groups" table includes only two group attributes: its name, and a unique group ID. Most of the time, this is sufficient; however, in case you need to add more attributes, patUser can be easily tweaked to work with this extra data.

    Let's alter the default "groups" table to include some additional fields, for description and location:


    # # Table structure for table `groups` # CREATE TABLE groups ( gid int(11) NOT NULL auto_increment, name varchar(50) default NULL, dsc varchar(255) NOT NULL default '', loc varchar(255) NOT NULL default '', UNIQUE KEY gid (gid) ) TYPE=MyISAM;
    While we're at it, let's also insert a few records into the new table:

    INSERT INTO groups (gid, name, dsc, loc) VALUES (1, 'Accounts', 'Billing and finance activities', 'AZ'); INSERT INTO groups (gid, name, dsc, loc) VALUES(2, 'Administration', 'Administrative activities', 'CA'); INSERT INTO groups(gid, name, dsc, loc) VALUES (3, 'Operations', 'Logistics and operations','CA');
    As before, I can retrieve this information via an SQL query,

    mysql> SELECT * FROM groups; +-----+----------------+--------------------------------+-----+| gid | name | dsc | loc |+-----+----------------+--------------------------------+-----+| 1 | Accounts | Billing and finance activities | AZ || 2 | Administration | Administrative activities | CA || 3 | Operations | Logistics and operations | CA |+-----+----------------+--------------------------------+-----+3 rows in set (0.00 sec)
    or have patUser do it for me via its getGroups() function:

    <?php // include classesinclude("../include/patDbc.php");include("../include/patUser.php");// initialize database layer$db = new patMySqlDbc("localhost", "db211", "us111", "secret");// initialize patUser$u = new patUser(true);// connect patUser to database$u->setAuthDbc($db);// set tables$u->setAuthTable("users");$u->setGroupTable("groups");// get group list$list = $u->getGroups(array("gid", "name", "dsc", "loc"));// print as tableecho "<h2>Groups</h2>";echo "<table border=1>";echo "<tr>";echo "<td><b>GID</b></td>";echo "<td><b>Name</b></td>";echo "<td><b>Description</b></td>";echo "<td><b>Location</b></td>";echo "</tr>";// iterate over listforeach ($list as $l){ echo "<tr>"; echo "<td>" . $l['gid'] . "</td>"; echo "<td>" . $l['name'] . "</td>"; echo "<td>" . $l['dsc'] . "</td>"; echo "<td>" . $l['loc'] . "</td>"; echo "</tr>";}echo "</table>";?>

    More PHP Articles
    More By icarus, (c) Melonfire


     

       

    PHP ARTICLES

    - Paginating Database Records with the Code Ig...
    - HTTP Headers in Web Development
    - Project Management: Administration
    - Building a Database-Driven Application with ...
    - User Authentication for a Project Management...
    - Introduction to the CodeIgniter PHP Framework
    - Adding Users for a Project Management Applic...
    - Migrating Class Code for a MIME Email to PHP...
    - Login and Logout Authentication for a Projec...
    - Composing Messages in HTML for MIME Email wi...
    - Project Management: Authentication
    - A Better Way to Determine MIME Types for MIM...
    - Project Management Overview
    - Handling Attachments in MIME Email with PHP
    - Completing the Project Management Application





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway