Hi Guys,
Here I explain how to develope secure login page based on user role like different types of user using PHP. First you create the registration form. After register your name into database then we can develope login page with PHP and MYSQL.
You have created your registration.php page successfully then its time to move ahead and learn how to create login page in PHP. For performing this operation using fordemo database and finforex_users table in login page.
This login script will take username and password entered by user through login.php page. The encryption password (MD5) is used here. Then it will match that username and password combination in database and when it finds then it check the role of the corresponding user and that combination exists in table it will allow user to login to corresponding page else it will show appropriate error message.
SQL query for finforex_users table:
CREATE TABLE IF NOT EXISTS `finforex_users` (
`userid` int(15) NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL,
`password` varchar(60) NOT NULL,
`role` varchar(20) NOT NULL,
`emailid` varchar(25) NOT NULL,
`phonenumber` varchar(15) NOT NULL,
PRIMARY KEY (`userid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
Database Connection: db.php
Code for login.php
Login