Press "Enter" to skip to content

User Registration Form in Codeigniter – Simple

Creating a user registration form is a common task in almost applications. User registration form includes student’s registration, employee registration or any account registration.

In CodeIgniter, every process is going under a MVC concept, that are Model, View and Controller.
So in our user registration form, HTML design for registration form is located at the view section contains textboxes for entering name, address, age, gender, phone, email, etc and a button to submit those data into the database.. it’s up to you to choose the items.
In this example program, we accept Name, Address, Age, Gender, Phone, Email address and password of the user.

As we shown in our tutorial, let’s create HTML design with on CodeIgniter View page.

View (registration.php)

<body bgcolor="#b1ac4e">
 <div class="maindiv">
 <form action="userregister" method="post">
     <td><b>Name </b> </td><td><input type="text" name="username"/></td>
     <td><b>address</b> </td><td> <textarea name="address" style="width:173px;"></textarea></td>
     <td> <b>Age  </b> </td><td><input type="number" name="userage"/></td>
     <td><b>Gender </b> </td><td>
     <select name="gender" style="width:173px;">
    <option value="Male">Male</option>
    <option value="Female">Female</option>
    <td><b>Phone</b> </td><td> <input type="number" name="userphone"/></td>
    <td> <b>Email  </b> </td><td><input type="email" name="usermail"/></td>
     <td> <b>Password  </b> </td><td><input type="password" name="userpwd"/></td>
    <td> <b> </b> </td><td> <input type="submit" value="Register" style="height: 25px; width: 100px; float: right;"/></td>

margin-top: 15%;
background: gray;
padding: 15px;
width: 275px;
height: auto;
border: 5px solid black;


Simple user registration in codeIgniter

Here table tag is used to align elements and contains some CSS codes for design.

Controller (user.php)

Here controller gets all View page posted data and sends them into the Model class.

class User extends CI_Controller
 public function register()
 public function userregister()
      $name = $this->input->post("username");
      $address = $this->input->post("address");
      $age = $this->input->post("userage");
      $gender = $this->input->post("gender");
      $phone = $this->input->post("userphone");
      $email = $this->input->post("usermail");
      $password = $this->input->post("userpwd");


$this->ProjectModel->USERNAME = $name;
$this->ProjectModel->ADDRESS = $address;
$this->ProjectModel->AGE = $age;
$this->ProjectModel->GENDER = $gender;
$this->ProjectModel->PHONE = $phone;
$this->ProjectModel->EMAIL = $email;
$this->ProjectModel->PASSWORD = $password;


Where function register() is our first controller function that loads the registration.php

Model (ProjectModel.php)

class ProjectModel extends CI_Model
  var $USERNAME = '';
  var $ADDRESS = '';
  var $AGE = 0;
  var $GENDER = '';
  var $PHONE = 0;
  var $EMAIL = '';
  var $PASSWORD = '';

public function adduser()
$data = array(
‘user_name’ => $this->USERNAME,
‘user_address’ => $this->ADDRESS,
‘user_age’ => $this->AGE,
‘user_gender’ => $this->GENDER,
‘user_phone’ => $this->PHONE,
‘user_email’ => $this->EMAIL,
‘user_pwd’ => $this->PASSWORD
$this->db->insert(‘table_user’, $data);


Database design:

CodeIgniter user register database design

Now you have successfully completed a user registration process. Now let’s create a login page to log a user in to the account using email and password.


  1. sudhin sudhin 7th September 2019

    pls share upload image for registration

    • Aslam Kakkove Aslam Kakkove Post author | 10th September 2019

      Here you can learn now to upload images or any files:

Leave a Reply