Home arrow PHP arrow Page 3 - User Authentication with patUser (part 1)

Dump Truck - PHP

Need to add authentication to your PHP-based Web application? Getit done in a jiffy with patUser, a PHP class which makes it possible torapidly add powerful user management capabilities to your Web application.

  1. User Authentication with patUser (part 1)
  2. Power User
  3. Dump Truck
  4. Zone Six
  5. Breaking It Down
  6. A Different Realm
  7. Icing On The Cake
By: icarus, (c) Melonfire
Rating: starstarstarstarstar / 15
April 23, 2003

print this article


Now that the hard sell is over and you're (hopefully) all set up with patUser, let's get things started. The first thing you need to do is set up a MySQL database to hold your user data - this database will be used by patUser to perform its various tasks.

The patUser distribution comes with an SQL dump file which you can use to create the necessary tables - you'll find it in the "sql/" directory of the distribution, and it looks something like this:

# # Table structure for table 'groups' # CREATE TABLE groups ( gid int(11) NOT NULL auto_increment, name varchar(50), UNIQUE gid (gid) ); # # Table structure for table 'permissions' # CREATE TABLE permissions ( id int(11) DEFAULT '0' NOT NULL, id_type enum('group','user') DEFAULT 'group' NOT NULL, part varchar(50), perm set('read','delete','modify','add') ); # # Table structure for table 'usergroups' # CREATE TABLE usergroups ( uid int(11) DEFAULT '0' NOT NULL, gid int(11) DEFAULT '0' NOT NULL ); # # Table structure for table 'users' # CREATE TABLE users ( uid int(10) unsigned NOT NULL auto_increment, username varchar(20) NOT NULL, passwd varchar(20) NOT NULL, email varchar(200), nologin tinyint(1) DEFAULT '0' NOT NULL, first_login datetime, last_login datetime, count_logins int(10) unsigned DEFAULT '0' NOT NULL, count_pages int(10) unsigned DEFAULT '0' NOT NULL, time_online int(11) DEFAULT '0' NOT NULL, PRIMARY KEY (uid), KEY username (username) );
Each of the tables above plays an important role in the patUser model:

  • The "users" table stores information about each user in the system - the user's login name and password, email address, and date of first and last login. Each user in this table is identified by a unique user ID.

  • patUser allows you to organize users into groups - the "groups" table stores a list of these groups. As with users, each group has a name and a unique group ID.

  • The "usergroups" table connects the records in the "users" and "groups" table together, specifying which users belong to which groups. patUser groups are not exclusive - a user may belong to more than one group at a time.

  • The "permissions" table makes it possible to assign permissions for a user or group. These permissions can be used to restrict user activities on a page-by-page basis.

    It's important to note, at this stage, that although the developers of patUser recommend using the schema above, there is no restriction on you, as a developer, creating and using your own set of tables. patUser's developers are well aware that different applications have different requirements and the schema above may not be suitable for all needs; therefore, they have designed the patUser library to be flexible enough for use with other, custom schemas as well (more on this shortly).

    >>> More PHP Articles          >>> More By icarus, (c) Melonfire

    blog comments powered by Disqus
  • escort Bursa Bursa escort Antalya eskort


    - Hackers Compromise PHP Sites to Launch Attac...
    - Red Hat, Zend Form OpenShift PaaS Alliance
    - PHP IDE News
    - BCD, Zend Extend PHP Partnership
    - PHP FAQ Highlight
    - PHP Creator Didn't Set Out to Create a Langu...
    - PHP Trends Revealed in Zend Study
    - PHP: Best Methods for Running Scheduled Jobs
    - PHP Array Functions: array_change_key_case
    - PHP array_combine Function
    - PHP array_chunk Function
    - PHP Closures as View Helpers: Lazy-Loading F...
    - Using PHP Closures as View Helpers
    - PHP File and Operating System Program Execut...
    - PHP: Effects of Wrapping Code in Class Const...

    Developer Shed Affiliates


    Dev Shed Tutorial Topics: