This PHP Login script will allow a user to login to your web site. It uses php sessions to keep your user logged in securely. This script requires PHP and a MySQL database. I may add a registration page, but right now you’ll need to add your users information directly into your database (passwords must be stored as md5).
First, download the example code
Step 2
Create a table in your database by executing this query:
1 2 3 4 5 6 7 8 9 | CREATE TABLE `user_accounts` ( `id` int(12) NOT NULL auto_increment, `fname` varchar(225) NOT NULL, `title` varchar(225) NOT NULL, `username` varchar(225) NOT NULL, `password` varchar(225) NOT NULL, `email` varchar(225) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=91; |
Step 3
Edit the connection info on the functions.php page.
1 2 3 | //connect to your DB// $connection = mysql_connect("localhost","username","password"); mysql_select_db("databasename",$connection); |
Step 4
Now your going to want to initiate sessions and include the functions.php file to the top of any page you will have users logging in.
1 2 3 4 5 6 7 | <?PHP session_start(); //INCLUDE THE ZLCMS CLASS include("inc/functions.php"); ?> |
Step 5
Now your going to want to add this fuction to the top of any page that you want to keep people out of. If they are logged in it will show the page if not it will redirect the user back to page of your choice.
1 2 3 4 | <?PHP //LOGIN VALIDATION checkLogin(); ?> |
Step 6
Now use the example code on the index.php page to test the login before you add it to a page!
Also, if you want a welcome message with the users first name, call this function:
1 2 | //display display message buildWelcome(); |
I’ll try to reply to any questions you might have about the installation of this script. Thank you for your interest in 2mellow.com. If this was useful please help us by clicking the social links below.

1 User Responded in " Free PHP Login "
very nice tuts….. keep on sharing this is a big help a biggener like me!
Leave A Reply Here