Create registration form in CodeIgniter

Create registration form in CodeIgniter


In this blog, we will learn how to create a registration form in the Codeigniter framework.

Related Topics:

Codeigniter Interview Questions
Error handling in CodeIgniter
Upload file in CodeIgniter

Creating a Registration Form

To create a registration form follow these steps:

Step 1 Create a table user in the database to store the form data.

user table structure

Step 2 Open the application/views directory and create a view file registration_view.php which contains the registration form.


<!DOCTYPE html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="">
<script src=""></script>
<script src=""></script>

<div class="container">
<h2>Registartion Form</h2>
<?php echo @$message; ?>
<form method="post" enctype="multipart/formdata">
<div class="form-group">
<label for="email">Name:</label>
<input type="text" class="form-control" name="name" placeholder="Enter Name">
<div class="form-group">
<label for="email">Email:</label>
<input type="email" class="form-control" name="email" placeholder="Enter Email ID">

<div class="form-group">
<label for="phone">Phone Number:</label>
<input type="text" class="form-control" name="phone" placeholder="Enter Phone Number">

<div class="form-group">
<label for="passsword">Password:</label>
<input type="text" class="form-control" name="password" placeholder="Enter Password">

<input type="submit" name="register" class="btn btn-success" value="Register"/>


Step 3 Open the application/models directory and create a model file Register_model.php.


class Register_model extends CI_Model
function insert_data($name,$email,$phone,$password)
$query=$this->db->query("select * from user where (email='".$email."' or phone='".$phone."')");
$row = $query->num_rows();
$data['message']="<h3 style='color:red'>This user already registered</h3>";
$query=$this->db->query("insert into user set name='$name',email='$email',phone='$phone',password='$password'");

$data['message']="<h3 style='color:blue'>You are registered successfully</h3>";



Step 4 Open the application/controllers directory and create a controller file Register_controller.php and put the given code on that file.


class Register_controller extends CI_Controller
public function __construct()
$this->load->model('Register_model'); ///load model

public function index()




Step 5 Run the Register_controller and register a user by using the given URL.


Click on the register button.

Best WordPress Hosting


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price

Leave a Reply

    Waiting for your comments