Login page (with database)
In earlier example, we learnt a simple login page with one single username and session.
Now we'll make it with more than one users using database. A sign in and login page will be there for users.
Following pages are made in this example.
In the first page, you'll have the option for Login and Sign In.
On Login, if user has entered correct credentials matching to database then he will be directed to data.php page. But if he has entered wrong information then incorrect username/password message will appear.
We have named our CodeIgniter folder as login_db. And our table name is signup.
We need to do some basic settings in our login_db CodeIgniter folder.
Go to autoload.php file, and do the following settings.
In the above snpashot, we have loaded the libraries and helper.
In database.php file, fill your username and database name. Our database name is codeigniter.
Now, we?ll start the example.
We have made file Main.php in application/controllers folder,
In application/views folder, login_view.php file is made.
In application/views folder, data.php file is made.
In application/views folder, signin.php file is made.
In application/views folder, invalid.php file is made.
In application/models folder, login_model.php file is made.
On entering the URL, http://localhost/login_db/index.php/Main/
Following page will appear.
Enter the information to Login.
After entering information, click on Login button. We have entered the wrong information and hence it will show the error message as shown below.
On entering the information from database, we' ll be directed to data.php page.
Click on Login button.
Clicking on Logout button, you'll be directed to the Main page.
On clicking Sign In, following page will appear.