Basic Login is a basic PHP login script that can be downloaded used and modified under the general user public license provisions.  This is not a PHP login script for a government institution or fortune 500 company as it uses standard encryption and cookie based user identification that a determined hacker might exploit.  It is, however, perfect for a standard website that would benefit from a basic PHP to MySQL login script that is easy to deploy and uses standard methods of restricting access and granting permissions.


Basic Login Demo:


Username
Password

Create a new account

Forgot Password / Change Password
Basic Login is FREE!

Download Now!

After writing countless PHP login scripts using various combinations of standard components tailored to the needs of the sites for which they were designed, I finally compiled the elements that I use most frequently into a basic
application that can be easily uploaded and deployed on any PHP project. While there are no grand inventions happening here, Basic Login should do what you need it to do right out of the gate.  Features, functions and components are as follows:

Latest updates / bug fixes: 02/04/2010

 

  • PHP to MySQL structure
  • Password encryptionEmail forgotten password hintEmail password change/ recreationNew user account creation with error handlingUser permission level controlUser login routing by permission on loginCentral configuration fileAdministrative user management reportFirst user gets admin permissions
  • Conditional content according to permission levels

*Note: Basic Login is a PHP security framework that is designed to protect PHP pages. All protected pages must have the .php extension I.E. index.php. In addition, a working copy of PHP 4 or greater must be running on the hosting server.


Basic Login Setup

  1. Download Basic Login files
  2. Unzip Basic Login files
  3. Upload Basic Login files to your server and put them in a directory of your choice. We recommend the root directory for simplicity
  4. Create users table in MySQL:
    Just run this query or cut and paste the following code into the SQL window of phpmyadmin or an equivalent MySQL control panel:

CREATE TABLE `users` (
`id` int(11) NOT NULL auto_increment,
`username` varchar(50) NOT NULL default '',
`password` varchar(150) NOT NULL default '',
`password_hint` varchar(255) NOT NULL default '',
`lastname` varchar(50) NOT NULL default '',
`firstname` varchar(50) NOT NULL default '',
`email` varchar(100) NOT NULL default '',
`phone` varchar(50) NOT NULL default '',
`address1` varchar(100) NOT NULL default '',
`address2` varchar(100) NOT NULL default '',
`city` varchar(80) NOT NULL default '',
`state` varchar(20) NOT NULL default '',
`zip` varchar(20) NOT NULL default '',
`country` varchar(50) NOT NULL default '',
`url` varchar(125) NOT NULL default '',
`permissions` varchar(20) NOT NULL default '1',
`notes` text NOT NULL,
PRIMARY KEY (`id`)
)        

  1. Open login_config.php and set the configuration values as desired
  2. Add your first user.  They will be configured as the administrator by default which means when they log in they will be able to see the administrator index...which means they will be able to see and manage other users on the system. 

Protect your pages:

In order to make sure users are logged before they can view a page on your site, put this code at the very top of that page you want to protect:

<? include"auth_check_header.php"; ?>

By top of the page we mean TOP OF THE PAGE!
That means no whitespace can come before your tracking code <? must be right in the top left corner. Not even a space can come before it!!! The reason is that the failed login redirect is a header and likely won't work unless it's the first thing on the page.

By default, Basic Login has 5 permission levels. If you want to make sure that only users who have a certain permission level or above can see a page then add a $permissions_level variable to your Auth check code. A sample would look like this. Again, put it at the very top of the page:

<?
$permission_level=3;
include"auth_check_header.php";
?>

Recent Updates:


02/04/10:

Updated traffic.php with pagination for those who want to use it. Requires the following table:

CREATE TABLE `traffic` (
`id` int(11) NOT NULL auto_increment,
`date` varchar(50) NOT NULL default '',
`ip` varchar(80) NOT NULL default '',
`link` varchar(200) NOT NULL default '',
`notes` text NOT NULL,
`site` varchar(255) NOT NULL default '',
`type` varchar(50) NOT NULL default '',
`page` varchar(50) NOT NULL default '',
PRIMARY KEY (`id`)
)

Then put something like this on pages you want to track:

<?

//Time & Date
$date = date ('m/d/y g:i a');

//IP Address
$ip = $_SERVER['REMOTE_ADDR'];

$type = "view";

$site = "basiclogin.com";

$page = "index.php";

//Query Block Tracking: WHERE '$ip' != '69.254.101.167'

$query = "INSERT INTO `traffic` (`date`,`ip`,`link`,`notes`,`site`,`type`,`page`)
VALUES ( '$date','$ip','$link','$notes','$site','$type','$page')";

// save the info to the database
$results = mysql_query( $query );?>

To track links put something like this in front of the link you want to track:

linktick.php?site=some_sitet&link=

So a tracked link would look like this

<a href="linktick.php?site=basiclogint&link=http://www.basiclogin.com">Tracked Link</a>


02/04/10:

Fixed permission issue in sample_page.php that may have confused some people when they set up their first test account. It had somehow gotten changed to permission level 5 so all test accounts would have bounced back to the login page.


12/18/09:

Thanks to Richard who pointed out a problem with the most recent zip file on some computers due to a freeware zip program that I was using so that I didn't have to pay the $29 to WinZip to renew my licence. Anyway, I went back and paid and recompiled the files so we should be back in business.


12/10/09:

A user named Jeehan pointed out that the system doesn't stop someone from entering a blank username. A simple fix has been added to the download version, or if you simply want to replace the two affected files, here is the code


09/16/09:

Basic Login PHP is listed on hotscripts.com, cnet.com, Scripts.com™ - Get the best scripts NOW! and other coding repositories.


09/15/09: Stupid mistake detected. Anyone who downloaded Basic Login in the last two days would have a version with the wrong login.php file. The problem has been fixed. I encourage you to re-download or copy the source code from this page if you have not already created your own login.php file. Sorry for the error! Thanks to Jeehan for bringing to our attention.


09/14/09: With Basic Login PHP, it is now easy to build in conditional content or events that are based on a particular users permission level. Just use a simple if then statement like this:

if($conditional_content_permissions>2)
{
echo"Some content that you can see if you are permission level three or higher ";
}
else
{
echo"Some content that users who are permission level two or less can see ";
}

Just set the number to the right permission level.


09/10/2009: Addition of user edit screens that allow for changes to user information and permission levels. Also allows for user delete. Linked to admin_index.php

Send Questions, Comments or Suggestions to info@basiclogin.com


Happy coding!