How to authenticate users

Visitors must register before posting comments on the page. This may also be necessary if you want them to participate in the site by submitting articles.

How the system works

The user enters a login and password into the form, and the form calls a PHP program, either to integrate this data if the user is a new user, or if it is necessary to log in to view the database and verify that the user exists and has provided information. correct password.
This data is added to the XML file.

XML-file

You must define the following tags and properties:

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

Register

If the user wants to register:
- the database is checked; login must be unique.
- the result is displayed in the message .
The PHP script loads the XML file, checks that the name is not yet in use, and if so, inserts a user profile with the end-of-root tag. The file is then saved.
If the name already exists, a message appears. In all cases, you are returned to the home page.
This is a simple process that can be performed without using any special XML functions.

See the register.php script in the archive below.

Login

When the user wants to log in:
- User name and password are compared to the contents of the database (demonstration simplified).
- if everything is in order, we continue; otherwise, you will be prompted to start over or register.
The code loads the XML file and places the content in tables, then compares the data.

See scenarios:

Real system

The real program is not so simple. If names and passwords are stored directly in an XML file, anyone can read it, and the user can use a name and password to log in.
We need to encrypt this data, either just the lines that contain it, or the entire XML file. And the program must be able to decode this data to search the list.
It seems easier to encode only strings, and we will use this method first in a real recording tool.

Download demo archive...