Codeigniter User Registration Form with MySQL, Bootstrap

By | December 22, 2016

In this tutorial we will cover User registration Form using Codeginiter. We had previously covered Codeigniter Login System. So today we decided we will share codeigniter user registration tutorial. Codeigniter is one of the most popular frameworks in PHP. It makes web development very simpler and is open source. For this tutorial we will simply use view and controller. For designing UI we will use simple css and bootstrap. And for backend to store user details we will use MySQL database.

Codeigniter User Registration Form

Before we start make sure you edit database file which is in config folder. And make sure you name your database codeigniter_insert, since for this tutorial I have named my database after that name.

Lets go ahead and check codeigniter registration tutorial

Codeigniter User Registration Form with MySQL, Bootstrap


CREATE DATABASE `codeigniter_insert` ;

`first_name` varchar(11) NOT NULL,
`last_name` varchar(55) NOT NULL,
`email` varchar(55) NOT NULL,
`password` varchar(55) NOT NULL
) ;

Codeigniter Code


I have created a file register_view.php which is a view file. It is designed using simple CSS and bootstrap. In this file we will add input fields for user registration. When user enter details and clicks on submit it will then call controller Register and inside Register controller it will then call function insert().

<!DOCTYPE html>

<link rel="stylesheet" href="">

<script src=""></script>

<script src=""></script>



 position: absolute;
 width: 220px;
 padding: 10px;
 border: 3px solid green;
 margin: 1; 




<nav class="navbar navbar-default">

<div class="container-fluid">
 <!-- Brand and toggle get grouped for better mobile display -->

<div class="navbar-header">
 <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
 <span class="sr-only">Toggle navigation</span>
 <span class="icon-bar"></span>
 <span class="icon-bar"></span>
 <span class="icon-bar"></span>
 <a class="navbar-brand" href="#">TechPlugg Dashboard</a>

<ul class="nav navbar-nav navbar-right">


<!-- /.navbar-collapse -->

<!-- /.container-fluid -->


<h1>Welcome to TechPlugg</h1>

We are a Tech Blog with Programming tutorials


<form enctype="multipart/form-data" action="<?php echo base_url(); ?>index.php/Register/insert" method="post" >

<div id ="main">
 <input type="text" name="first_name" placeholder="Enter first Name" />

 <input type="text" name="last_name" placeholder="Enter last Name"/>

 <input type="text" name="email" placeholder="Enter your Email ID" />

 <input type="password" name="password" placeholder="Enter a password"/>

 <center><input type="submit" value="Register" class="btn btn-primary"/></center>






Register.php is a controller which will contains insert function. It is a user defined function. Function collects all the values submitted in the form and stores in data array and then further inserts into our table profile. After successful query it then redirects user to success_view.php file which will show message for successful user registration.

<?php class Register extends CI_Controller { function __construct() { parent::__construct(); $this->load->helper(array('form', 'url'));

 //index function
 function index()
 //load file upload form

 function insert()

 $first_name = $this->input->post('first_name');
 $last_name = $this->input->post('last_name');
 $email = $this->input->post('email');
 $password = md5(trim($this->input->post('password')));
 if($first_name !='' && $last_name !='' && $email !='' && $password!='')
 $data = array('first_name'=>$first_name,'last_name'=>$last_name,'email'=>$email,'password'=>$password);
 function success_register()



<?php echo "Registration Successful"; ?>

<a href="<?php echo base_url(); ?>index.php/Register/">Register new account</a>

It simply shows success message. You can edit this file the way you like. It’s simply a message file.


You might like Image Uploading using Codeigniter.

I hope Codeigniter user registration was simple. If you want to ask any doubt please comment below. In the upcoming posts I will cover more such important codeigniter tutorials.