PHP login script with advanced features – Documentation
Download the script from the DOWNLOAD page and extract it to your SITE ROOT
Action File name File Content Open the file dbtables.sql It contains the details of required MySQL tables
All the tables needed for the Login System are written in the file dbtables.sql. You can look at the file and create each table manually or you can just run the file with mysql and it will create all the necessary tables automatically or you can also copy and paste the contents of this file in mysql query window and run the query.
# # dbtables.sql # # Simplifies the task of creating all the database tables # used by the login system. # # Can be run from command prompt by typing: # # mysql -u yourusername -D yourdatabasename < dbtables.sql # # That is with dbtables.sql in the mysql bin directory, but # you can just include the path to dbtables.sql and that is # fine too. # # Please subscribe to our feeds at http://blog.geotitles.com for more such tutorials # # # Table structure for users table # DROP TABLE IF EXISTS blog_users; CREATE TABLE blog_users ( username varchar(30) primary key, password varchar(32), userid varchar(32), userlevel tinyint(1) unsigned not null, email varchar(50), timestamp int(11) unsigned not null ); # # Table structure for active users table # DROP TABLE IF EXISTS blog_active_users; CREATE TABLE blog_active_users ( username varchar(30) primary key, timestamp int(11) unsigned not null ); # # Table structure for active guests table # DROP TABLE IF EXISTS blog_active_guests; CREATE TABLE blog_active_guests ( ip varchar(15) primary key, timestamp int(11) unsigned not null ); # # Table structure for banned users table # DROP TABLE IF EXISTS blog_banned_users; CREATE TABLE blog_banned_users ( username varchar(30) primary key, timestamp int(11) unsigned not null );
Action File name File Content Open and Edit constants.php(found in include folder) It contain all the constants and important information used by the login system
The constants.php file contains all the important information, settings and constants used by the login script, Please open this file in a text editor like Notepad or Dreamweaver and edit the file, declaring all the constants given below.
define("DB_SERVER", "localhost");//If you don't know what to edit here, then leave it as it is define("DB_USER", "database_username");//enter your database username define("DB_PASS", "database_password");//database password define("DB_NAME", "database_name");//database name
define("ADMIN_NAME", "admin"); define("GUEST_NAME", "Guest"); define("ADMIN_LEVEL", 9); define("USER_LEVEL", 1); define("GUEST_LEVEL", 0);
/** * Timeout Constants - these constants refer to * the maximum amount of time (in minutes) after * their last page fresh that a user and guest * are still considered active visitors. */ define("USER_TIMEOUT", 10); define("GUEST_TIMEOUT", 5); /** * Cookie Constants - these are the parameters * to the setcookie function call, change them * if necessary to fit your website. If you need * help, visit www.php.net for more info. * */ define("COOKIE_EXPIRE", 60*60*24*100); //100 days by default define("COOKIE_PATH", "/"); //Available in whole domain
define("EMAIL_FROM_NAME", "Your Name"); define("EMAIL_FROM_ADDR", "email@example.com"); define("EMAIL_WELCOME", true);//set this false if you do not want your users to receive a welcome Email after registration
After editing the constants.php file. Save it and upload the entire Script to the server
In order for you to use the Login system as an administrator , Register yourself in the Sign-Up page ( register.php) with username – Admin
Great! Now you are finished with everything, just login and enjoy
you can make customization to the script, as per your needs.
If you need any other improvisations to this script or want to request a new tutorial, Please Contact me.
Click here to go back to the tutorial.