How to authenticate users

♠ Posted by Unknown in at 09:27
Visitors must register before placing comments on a page. This may also be required if you want them to contribute to the site by submitting articles.

How the system works

The user types a username and password in a form and a PHP program is called by the form or to integrate this data if a new user, or when you want to browse log the base and verify that the user exists and has set a good password.
This data is added to an XML file.

The XML file

These tags and properties must be set:

<users>
  <user login="" password="" email="" />
   etc...
</users>

To register

If the user wants to record:
- A check is made in the database, the login must be unique.
- A message displays the result.
The script written in PHP language load the XML file, verifies that the name is not already used, and in this case it inserts the user profile with the end of root tag marker. Then save the file.
If the name already exists, a message is displayed. In all cases we return to the main page.
It's a simple process that can be accomplished without using any particular XML function.


View register.php script.

To log

When the user wants to log:
- The name and password are compared to the contents of the database (the demo is simplified).
- If everything is ok we continue, otherwise a message proposing to start or to register.
The code loads the XML file and places the contents in tables, and compares the data.

See scripts:


  • logcheck.php Parse the database, checks if the login exists in this case it loads logok.php otherwise load login.php.
  • login.php The username entered does not exist. Enter another name (in the demo password is not required).
  • logok.php The name is recognized, a message is displayed and then reload the main page.
The real system

The actual program is not as simple. If the names and passwords are stored directly in an XML file, it can be read by anyone and you can take a name and password to log in with.
We need to encrypt data, only the channels that contain either the entire XML file. And the program must be able to decode the data to search the list.
It seems easier to just encode the chains and we first use this method in the actual recording tool.

Download the archive of the demo ...


                                      DOWNLOAD 


0 comments:

Post a Comment