PHP
  Home arrow PHP arrow Page 3 - Building a Logout Class
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

Building a Logout Class
By: Chris Neeman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 6
    2007-09-05

    Table of Contents:
  • Building a Logout Class
  • Recording the Logout Session
  • The Database Tables
  • Testing the Classes

  • 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


    Building a Logout Class - The Database Tables


    (Page 3 of 4 )

    The database table that is used to track user log in and log out is very simple. Below is the SQL to create a table for it:

    # Host: localhost
    # Database: intranet
    # Table: 'logtbl'
    #

    CREATE TABLE `logtbl` (
      `logid` int(4) NOT NULL auto_increment,
      `u_id` int(4) NOT NULL default '0',
      `start_sess` datetime NOT NULL default '0000-00-00 00:00:00',
      `end_sess` datetime NOT NULL default '0000-00-00 00:00:00',
      `duration` varchar(20) NOT NULL default '',
      PRIMARY KEY  (`logid`)
    ) TYPE=MyISAM;

    It has the following fields:

    logid          - Stores a unique number for each new record
    u_id           - Stores the user id of the currently logged in user
    start_sess - time and date of the user log in
    end_sess   - time and date of user log out
    duration     - duration in hours, minutes and seconds between start_sess and end_sess date time values

    The all important users table contains the usernames and passwords of all the intranet users.  Below is the SQL that will create this table. I've also included sample data for the table. Notice the format in which the email addresses are written. The checkemail() function in the validate class that we discussed in earlier articles checks for this format to verify the validity of a email address:

    # Host: localhost
    # Database: intranet
    # Table: 'users'
    #

    CREATE TABLE `users` (
      `uid` int(11) NOT NULL auto_increment,
      `name` varchar(20) NOT NULL default '',
      `sname` varchar(20) NOT NULL default '',
      `upass` varchar(8) NOT NULL default '',
      `access_level` enum('admin','regular') NOT NULL default
    'regular',
      `email` varchar(100) NOT NULL default '',
      `depid` int(2) NOT NULL default '0',
      `isActive` int(2) NOT NULL default '0',
      PRIMARY KEY  (`uid`)
    ) TYPE=MyISAM

    The table has the following fields:

    uid          - creates a unique id for every user
    name      - stores the name of the user
    sname    - stores the surname of the user
    upass     - stores the user password
    access   - stores the access level either admin or normal
    email     - stores the email address of the user
    depid     - stores the department id of the user
    isactive - sets the user account to either  1 for active or 0 for  inactive

    And here's the sample data for the table:

    INSERT INTO `users` VALUES (1, 'mubasen', 'gaseb', 'pass',
    'admin', 'mubasen.gaseb@damaranet.com', 3, 1);
    INSERT INTO `users` VALUES (2, 'dantago', 'nanub', 'sunday',
    'regular', 'dantago.nanub@damaranet.com', 1, 1);
    INSERT INTO `users` VALUES (3, 'axaro', 'garoeb', 'monday',
    'regular', 'axaro.garoeb@damaranet.com', 2, 1);
    INSERT INTO `users` VALUES (4, 'koro', 'garises', 'teusday',
    'admin', 'koro.garises@damaranet.com', 1, 1);
    INSERT INTO `users` VALUES (5, 'saridao', 'taurob', 'thursday',
    'admin', 'saridao.taurob@damaranet.com', 2, 1);

    More PHP Articles
    More By Chris Neeman


     

       

    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 6 hosted by Hostway