Quick PHP Password Protection Readme
Quick PHP Password Protection is a single user PHP login system which is secure, quick to implement, and requires no database. Perfect for small web apps, scripts, and personal pages which only have a single admin using them.
Example Usage
<?php require_once "../quickprotect.class.php"; $quickprotect = new quickprotect(); $quickprotect->checkLoginAndDirect(); ?>
That's all it takes! One line of effective code (not counting the class include and init), and you've password protected a page!
Features
- Secure. Tested brute force and SQL Injection proof.
- Extremely easy implementation. One line of code, and you're done.
- No database required. Settings stored in INI file.
- Note: this is a single user system ONLY. Multiple users are not supported. This is designed for small projects, web apps, and personal pages.
How to implement
- Step 1: Upload login.php, login.ini.php, and quickprotect.class.php to your server
- Step 2: Configure login.ini.php with the appropriate settings
- Step 3: Implement the password protection in your app by using the code above. Whichever pages contain those 3 lines of code will be password protected
Additional Functions
How do I check if a user is logged in?
$quickprotect->is_logged_in(); //Returns true or false
How do I change a password?
Method 1: Using the built-in function
$quickprotect->setNewPassword($oldusername, $oldpassword, $newpassword);
You may use this form template:
Simply pass those values to the function, and your password will change
Method 2: Manually
Change the value of ADMIN_PW in the INI file to the sha1 hash of the password you want to use.
How do I do a logout?
Simply go to login.php?do=logout.