Home » CodeIgniter Database Login Form

CodeIgniter Database Login Form

by Online Tutorials Library

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 application/controllers

  • Main.php

In application/views

  • login_view.php
  • invalid.php
  • data.php
  • signin.php

In application/models

  • login_model.php

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.

Login page 1

We need to do some basic settings in our login_db CodeIgniter folder.

Go to autoload.php file, and do the following settings.

Login page 2

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.

Login page 3

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.

You may also like