login system class

This is a discussion on "login system class" within the PHP Forum section. This forum, and the thread "login system class are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Aug 26th, 2007, 17:06
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Wink login system class

Hey does anyone know of a login script someone has someone has wirtten that uses classes.
like the tutorial on kirupa.com
Each users properties are in a class and that class is in another class:
PHP: Select all

class User {
    private 
$name;
    
    function 
__construct$attribs ) {
        
$this->name $attribs['name'];
    }
    
    
/* name methods */
    
function setName$val ) {
        
$this->name $val;
        return;
    }
    
    function 
getName() {
        return 
$this->name;
    }
}

/* Contains a group of User objects */
class UsersGroup {
    private 
$name;            // name of group
    
private $group = array();    // group of User objects
    
    
function __construct() {
        
/* Connect to DB using Settings */
        
$link mysql_connect(
            
Settings::$DATABASE['host'],
            
Settings::$DATABASE['username'],
            
Settings::$DATABASE['password']
            );
        
mysql_select_db Settings::$DATABASE['database'], $link );
        
        
/* Get table names from Settings class */
        
$tbl_users Settings::$TABLES['tbl_users'];
        
        
/* Query */
        
$sql "SELECT    user_id AS ID,
                user_name AS name
            FROM $tbl_users"
;
        
$result mysql_query$sql ) or die(mysql_error());
        
        
/* Adds user to group with each row of data */
        
while( $row mysql_fetch_array($result) ) {
            
$this->addUser$row );
        }
    }
    
    
/*
    Add a user to Group
    Does simple check to see if we pass an array (like $attribs)
     or if we pass an object (like a User object)
    */
    
function addUser$user ) {
        if( 
is_object$user ) ) {
            
array_push$this->group$user );
        }
        if( 
is_array$user ) ) {
            
$noob = new User$user );
            
array_push$this->group$noob );
        }
        return;
    }
    
    
/* Returns the group (which is an array) */
    
function getUsers() {
        return 
$this->group;
    }
}

/* Holds our site settings */
class Settings {
    static 
$DATABASE = array(
        
// change these as needed 'database' => 'kirupa_oop', // May need to be changed 'username' => 'root', 'password' => '', 'host' => 'localhost' ); static $TABLES = array( // reference to table name => actual MySQL table name 'tbl_users' => 'users' ); } 
I'd like to make a system where users properties, (like user type: normal, moderator, admin) are stored in a class, and seeing somone elses code for this should help
Thankss
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote

  #2 (permalink)  
Old Aug 28th, 2007, 03:09
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: login system class

I have a normal user and admin script which allows an admin to ban users in the making

now it also can change users ranks and posts
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)

Last edited by alexgeek; Aug 28th, 2007 at 03:57. Reason: new stuff
Reply With Quote
Reply

Tags
class, log, login, users

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
News System login problem Andrew1986 Classic ASP 3 Dec 20th, 2007 23:58
[SOLVED] div class and div id danny322 Web Page Design 1 Nov 22nd, 2007 12:52
array of class janper Flash & Multimedia Forum 4 Apr 9th, 2007 13:54
PHP login system robertboyle PHP Forum 1 Jun 26th, 2006 14:38
some type of member login/register system Lucid. Web Page Design 22 Feb 3rd, 2006 17:19


All times are GMT. The time now is 11:29.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43