Location: PHPKode > scripts > SPL and Iterators > spl-and-iterators/users/ouser.readme.txt

This package is meant to manage users, for different websites or web applications.
My issue was that I often have basic websites to create, with a user management, and basically, the management does not change.
But, users' properties change. Sometimes, you need the email, sometimes not...
It's based on PHP5 iterators, and an XML configuration file describing users properties and session properties.

You will also need a DB class (you will find a very basic one here, with only needed features for the example).
Beware, methods name used are :
fetch_assoc ()
query ()
That's all. So, you have to use a class with these methods names, or modify the oUser class to use your own methods.

This package is not complete...because the complete one, I use it for my work ;-) 
Again, I give a simplified version to the community to show how Iterators can be used in a more complicated way that is shown on most tutorials on the web.
With this simplified version, you can :
authenticate a user
create a user
get a user
modify a user

You'll finc 2 example files : 
test.php fait mainly shows how iterators are used to walk through a user.
exemple.php shows a basic authentication form : fill it. If you do not exist in the database, you are created. If you exist, you are authenticated.
If you input the good email but the wrong password, there's an authentication error. That's all :-)
You will need a mysql table (I chose mysql because it is the most widely used DB) :
DB name : bdd_test
Table name : users
Fields :
user_id (int) autoincrement
user_email (varchar)
user_pwd (varchar)
user_nom (varchar)

Now, the XML configuration file : 
You must have under the root, 2 nodes :
Each of them MUST have a sub node ID.
The other ones are not mandatory.
Here are the implemented properties for sub nodes :
BDD_NAME : name of your DB field for this property (example : EMAIL -> BDD_NAME = user_email
TYPE : well...the property type (in this example, only int or string)
They are mandatory.
Now, for the optional ones :
IDENT i: this property is used for the authentication. IN this example, EMAIL and PASSWORD are used, and mandatory, for the authentication.
MANDATORY : this property is mandatory for a user's creation. 
DEDOUBLE : when you try to authenticate, this property will be used to see if there already is a user in the DB with the same account. Here, in this example, if a user input an existing email, and a wrong password, we will find out that the email is "DEDOUBLE", and that it already exists in the DB. But the password is wrong... : user already exists, wrong authentication.

You can use as many properties as you want. 

That's all.
Return current item: SPL and Iterators