PHP login system

PHP Embeddable and Highly Secure PHP Authentication System with Login, Signup, User Profiles, Profile Editing, Account Verification via Email, Password Reset System, Remember Me Feature, Automatic Logout on Inactivity, Global ERROR & STATUS variable system, Authentication checks and more


  • PHP
  • Apache server
  • MySQL
  • PHPMailer
  • Bootstrap
  • JQuery


  • Import the file assets/setup/DBcreation.sql into the current DBMS. The dump file also creates the database (named klik_loginsystem), so no prior action is needed. If database name needs to be updated, change it in the dump file where the database title is declared.
  • Edit the file assets/setup/env.php and setup the Application information, Database connection and SMTP server. Port value is usually not needed in Database connections, so only edit if you know what you are doing. The email server (and the connected email account) will be used to send confirmation, validation and notification emails.


if (!defined('APP_NAME'))                       define('APP_NAME', 'Login System');
if (!defined('APP_ORGANIZATION'))               define('APP_ORGANIZATION', 'KLiK');
if (!defined('APP_OWNER'))                      define('APP_OWNER', 'msaad1999');
if (!defined('APP_DESCRIPTION'))                define('APP_DESCRIPTION', 'Embeddable PHP Login System');

if (!defined('ALLOWED_INACTIVITY_TIME'))        define('ALLOWED_INACTIVITY_TIME', time()+1*60);

if (!defined('DB_DATABASE'))                    define('DB_DATABASE', 'klik_loginsystem');
if (!defined('DB_HOST'))                        define('DB_HOST','');
if (!defined('DB_USERNAME'))                    define('DB_USERNAME','root');
if (!defined('DB_PASSWORD'))                    define('DB_PASSWORD' ,'');
if (!defined('DB_PORT'))                        define('DB_PORT' ,'');

if (!defined('MAIL_HOST'))                      define('MAIL_HOST', '');
if (!defined('MAIL_USERNAME'))                  define('MAIL_USERNAME', '[email protected]');
if (!defined('MAIL_PASSWORD'))                  define('MAIL_PASSWORD', 'example-password');
if (!defined('MAIL_ENCRYPTION'))                define('MAIL_ENCRYPTION', 'ssl');
if (!defined('MAIL_PORT'))                      define('MAIL_PORT', 465);

Existing Account(s)

The database already contains a sample account to test things out with. Use that or head over to the signup page and start making new accounts.

// credentials for existing account

username: supahot
password: aaaaaa

Project File Structure

Path / FilePurpose
[accessible URLs/Pages]All folders in root directory except assets
assets/cssFolder for global or layout-specific custom CSS files.
assets/imagesImages used in Application UI or git README.
assets/includesFunctions or classes.
assets/jsCustom js files.
assets/setupProject configuration and setup files.
assets/uploadsFolder for all content uploaded by application users.
assets/uploads/usersImages uploaded by users.
assets/vendorFolder for all plugins/resources.
File structure

Building on top of System

Once this Authentication system has been set up, it can be easily built upon this way: New pages can be quickly added by creating more folders in the root directory, with the main frontend file being index.php, backend functionalities in the includes subfolder and custom styling in the custom.css file, present in the same top-level folder as that of index.php

New function groups or classes can be created in new files in the assets/includes/ folder, and will have to be included in relevant pages. if the added functionalities are mostly universal, they can be required in the assets/layouts/header.php file (this includes them for all frontend files but backend files will still have to be individually linked). In the same way, more global css files can be saved in assets/css and included in the header.php layout file. Same convention will hold for JS files, with the scripts being in assets/js/ and included in assets/layouts/footer.php file.

Additional plugins or offline resources can be placed in the assets/vendor/ folder and linked-to in either the header or footer layout file, depending on the file type to be linked.

A good convention to adopt while building on top of this would be to adopt the same file structure conventions as in this system, in order to avoid extra and/or unneeded effort to synchronise the entire project. The system has already been made with the default PHP Application file structure in order to avoid most conflicts



  • PHP-7.3.11
  • MySQLi API
  • HTML5
  • CSS3

Development Environment

  • Apache-2.4.41
  • Windows 10

External Resources/Plugins

  • PHPMailer-6.0.6
  • Bootstrap-4.3.1
  • Font awesome-5.12.0
  • JQuery-3.4.1


Easy Integration / Embedding

The application is designed to be easily embeddable and is meant to be built upon. The current UI has been built mostly on raw bootstrap, and is meant to be completely replaced rather than improved upon. The purpose of this project is to provide the needed backend functionality, and all UI elements should be replaced and/or rebuilt when creating a separate application.

It is recommended that the application be installed/embedded into the project before creation of application backend _and preferably the frontend as well). Otherwise, if the existing file structure conflicts with this project’s, it may cause problems and will make it difficult to re-synchronise the entire project again

The project was created with the standard PHP development file structure, in order to maintain flexibility. Simply add more features/ pages in the same way the sample page-folders in the root folder are created.

n each page folder, the index.php is the main target page, the includes folder holds the backend functionality and the custom.css enables custom designs on top of a global css file without interfering with other pages.

Leave a Comment