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  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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: starstarstarstarstar / 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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





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