I have been working hard these past few days. Starting from scratch about 3 times to get things perfect. And yet its not at the point I would like it to be. So this would be version 1.0 of my BHLogin program. And you should consider this a beta program.
BHLogin provides a very simple way for site administrators to add user authentication to their sites. Just by adding 4 lines of code to the beginning of the page you now have a locked down page that requires user to login to see.
I am not going to go into major detail about the program because I will be making a manual and include much more support for version 2.0 but I can at least tell you how to get started.
You can start by downloading one of these amazing archives.
- bhlogin.7z – 126 KB
- bhlogin.zip – 200 KB
- bhlogin.tar.gz – 155 KB
Start by extracting one of these archives onto your site.
Open “bhlogin/config.php” and edit the settings to work with your server.
Open a web browser and run “bhlogin/install.php”.
After install is done with no errors, delete “bhlogin/install.php” so nobody can mess with your installation.
You can now login to “bhlogin/admin/” as User:admin, Pass:admin to change your username and password, create new users, and delete users.
If you visit “bhlogin/page.php” you will see that you are required to login to view that page. If you open that page in your favorite text editor you will see the code that looks like this:
<?php
// Start basic session handleing
session_start();// Load bhlogin.php
require (‘bhlogin.php’);// Load bhlogin class
$bhlogin = new bhlogin();// Require authentication
// auth($auth_level, $page = NULL)
// $auth_level can be 1 = User, 2 = Manager, 3 = Administrator
// $page can be left blank and $after_login (in config.php) will be used instead. This is the page to redirect to after login.
$bhlogin->auth(1, $_SERVER['REQUEST_URI']);
?>
This code is required to add authentication to your pages. I added comments so you can see what is what.
Let me know what you think in the comments below.
Plans for version 2.0
- Allow users to sign up
- Allow users to change their settings
- Verify email with link emailed to user
- Ability to email a user from the admin panel
- Anything else I can think of.
There is still lots of work to do. But I am hoping to be done it before I leave for Basic Training.
