HomePHP Adding Users for a Project Management Application
Adding Users for a Project Management Application
In the last article we looked at how a user is authenticated and granted access if the login credentials are correct. Now, for any user to log in he or she needs to exist in the database. To put user information in the database we will need scripts through which we can do just that, hence the topic of this article. This is the third part of a four-part series on the authentication details involved in building a project management application.
The next two scripts that we will be discussing will enable administrators to create a new user, with a password that is auto generated. We will look in detail at how it is done.
The new user script
This script is responsible for creating the user. A user can only be created by an administrator. This is common practice in any intranet environment. A new employee will usually be assigned a username and password by the systems administrator or someone with equivalent authority. And since we are using this application on the assumption that it is going to be used in an intranet, we are going to follow the same tradition.
The password will be auto generated by a function that I've included in the functions file. So the moment this registration script is activated, a seven-character-long password will be generated. This password will then be sent to the user when the administrator finishes creating the user profile. This script is located in the admin section of the application. In the next section you will see the code that makes creating a new user possible.