Skip to content
This repository was archived by the owner on Mar 15, 2018. It is now read-only.

Latest commit

 

History

History
84 lines (61 loc) · 1.45 KB

File metadata and controls

84 lines (61 loc) · 1.45 KB

PHP Login Class

This is a basic PHP login class for authenticating users through a MySQL Database.

  • Usernames
  • Hashed & Salted Passwords

Usage

//Initialize the class 
require_once 'login.php';
$login = new login("127.0.0.1", "web_login", "TotallySecurePassword", "webSite_Storage", "3306", "storage_")

//Create user Hello with the password of World
$login->createAccount('Hello', 'World');

//Check an account password
if ($login->checkPassword('Hello', 'World')) { 
    //Password is correct
} else {
    //Password is incorrect
}

Functions

  • Initialize
/**
* Initialisation is done when instantiating the class like so
*/
$login = new login("127.0.0.1", "web_login", "TotallySecurePassword", "webSite_Storage", "3306", "storage_")
  • Create A User Account
$login->createAccount(string $username, string $password);

/*
* Returns true on success, returns false on error
*/
  • Delete a User Account
$login->deleteAccount(string $username);

/*
* Returns true on success, returns false on error
*/
  • Change a User Account Password
$login->changePassword(string $username, string $password);

/*
* Returns true on success, returns false on failiure.
*/
  • User Permissions
//TO BE COMPLETED
  • Password Checking
$login->checkPassword(string $username, string $password);

/*
* Returns true on correct password, returns false on incorrect password
*/