Skip to content
pakainfo

Pakainfo

Web Development & Good Online education

  • Home
  • Blog
  • Categories
  • Tools
  • Full Form
  • Guest Post
  • Advertise
  • About
  • Contact Us

Complete User Registration system using Codeigniter 3

November 4, 2018 Pakainfo Programming, Codeigniter, Mysql, Mysqli, php Leave a comment

Today, We want to share with you Complete User Registration system using Codeigniter 3.In this post we will show you User Registration and Login System in CodeIgniter 3, hear for Complete User Registration system using PHP and MySQL database we will give you demo and example for implement.In this post, we will learn about Codeigniter 3 – User Registration and Login Example & Tutorial with an example.

Complete User Registration system using Codeigniter 3

Contents

  • Complete User Registration system using Codeigniter 3
    • Database table creation
    • Autoload Libraries & Helper
    • Codeigniter Database Connection
    • Codeigniter Define Controllers (Signup.php)
    • Controllers(SignIn.php)
    • Controller(Private_area.php)
    • Models(Signup_model.php)
    • Models(SignIn_model.php)
    • Views(signup.php)
    • Codeigniter Views(email_verification.php)
    • Codeigniter Views(signin.php)
    • Read
    • Summary
    • Related posts

There are the Following The simple About Complete User Registration system using Codeigniter 3 Full Information With Example and source code.

As I will cover this Post with live Working example to develop codeigniter login and access management system, so the registration and login form in php Codeigniter 3 and mysql with validation code free download for this example is following below.

Database table creation

Create Codeigniter Database with Table

--
-- Database: `atmiya25`
--

-- --------------------------------------------------------

--
-- Table structure for table `members_mst`
--

CREATE TABLE `members_mst` (
  `id` int(11) NOT NULL,
  `name` varchar(250) NOT NULL,
  `email` varchar(250) NOT NULL,
  `password` text NOT NULL,
  `member_key_verification` varchar(250) NOT NULL,
  `is_email_verified` enum('no','yes') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `members_mst`
--
ALTER TABLE `members_mst`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `members_mst`
--
ALTER TABLE `members_mst`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

Autoload Libraries & Helper

autoload.php

$autoload['libraries'] = array('session','database');
$autoload['helper'] = array('url','form');

Codeigniter Database Connection

application/config/database.php

<?php

$active_group = 'default';
$query_builder = TRUE;

$db['default'] = array(
 'dsn' => '',
 'hostname' => 'localhost',
 'username' => 'jaydeep_gondaliya',
 'password' => '[email protected]',
 'database' => 'atmiya25',
 'dbdriver' => 'mysqli',
 'dbprefix' => '',
 'pconnect' => FALSE,
 'db_debug' => (ENVIRONMENT !== 'production'),
 'cache_on' => FALSE,
 'cachedir' => '',
 'char_set' => 'utf8',
 'dbcollat' => 'utf8_general_ci',
 'swap_pre' => '',
 'encrypt' => FALSE,
 'compress' => FALSE,
 'stricton' => FALSE,
 'failover' => array(),
 'save_queries' => TRUE
);

?>

Codeigniter Define Controllers (Signup.php)

<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Signup extends CI_Controller {

 public function __construct()
 {
  parent::__construct();
  if($this->session->userdata('id'))
  {
   redirect('private_area');
  }
  $this->load->library('form_validation');
  $this->load->library('encrypt');
  $this->load->model('signup_model');
 }

 function index()
 {
  $this->load->view('signup');
 }

 function validation()
 {
  $this->form_validation->set_rules('member_name', 'Name', 'required|trim');
  $this->form_validation->set_rules('member_email', 'Email Address', 'required|trim|valid_email|is_unique[members_mst.email]');
  $this->form_validation->set_rules('member_password', 'Password', 'required');
  if($this->form_validation->run())
  {
   $member_key_verification = md5(rand());
   $encrypted_password = $this->encrypt->encode($this->input->post('member_password'));
   $data = array(
    'name'  => $this->input->post('member_name'),
    'email'  => $this->input->post('member_email'),
    'password' => $encrypted_password,
    'member_key_verification' => $member_key_verification
   );
   $id = $this->signup_model->insert($data);
   if($id > 0)
   {
    $subject = "Please Your Member verify email for signin";
    $message = "
    <p>Hi Dear".$this->input->post('member_name')."</p>
    <p>This is email verification mail from Codeigniter SignIn Signup Management. For complete Step Vy Step process and signin into Management. First of all you want to verify you email by click this Link <a href='".base_url()."signup/member_email_verify/".$member_key_verification."'>link</a>.</p>
    <p>Once you click this link member email will be verified and you can signin into Management.</p>
    <p>Thanks,</p>
    ";
    $config = array(
     'protocol'  => 'smtp',
     'smtp_host' => 'smtpout.secureserver.net',
     'smtp_port' => 80,
     'smtp_user'  => 'YOUR_USERNAME', 
                  'smtp_pass'  => 'YOUR_PASSWORDS', 
     'mailtype'  => 'html',
     'charset'    => 'iso-8859-1',
                   'wordwrap'   => TRUE
    );
    $this->load->library('email', $config);
    $this->email->set_newline("\r\n");
    $this->email->from('[email protected]');
    $this->email->to($this->input->post('member_email'));
    $this->email->subject($subject);
    $this->email->message($message);
    if($this->email->send())
    {
     $this->session->set_flashdata('message', 'Check in member email for email verification mail');
     redirect('signup');
    }
   }
  }
  else
  {
   $this->index();
  }
 }

 function member_email_verify()
 {
  if($this->uri->segment(3))
  {
   $member_key_verification = $this->uri->segment(3);
   if($this->signup_model->member_email_verify($member_key_verification))
   {
    $data['message'] = '<h1 align="center">Member Email has been successfully verified, now you can signin from <a href="'.base_url().'signin">here</a></h1>';
   }
   else
   {
    $data['message'] = '<h1 align="center">Sorry, Invalid Link</h1>';
   }
   $this->load->view('email_verification', $data);
  }
 }

}

?>

Controllers(SignIn.php)

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class SignIn extends CI_Controller {

 public function __construct()
 {
  parent::__construct();
  if($this->session->userdata('id'))
  {
   redirect('private_area');
  }
  $this->load->library('form_validation');
  $this->load->library('encrypt');
  $this->load->model('signin_model');
 }

 function index()
 {
  $this->load->view('signin');
 }

 function validation()
 {
  $this->form_validation->set_rules('member_email', 'Email Address', 'required|trim|valid_email');
  $this->form_validation->set_rules('member_password', 'Password', 'required');
  if($this->form_validation->run())
  {
   $result = $this->signin_model->can_signin($this->input->post('member_email'), $this->input->post('member_password'));
   if($result == '')
   {
    redirect('private_area');
   }
   else
   {
    $this->session->set_flashdata('message',$result);
    redirect('signin');
   }
  }
  else
  {
   $this->index();
  }
 }

}

?>

Controller(Private_area.php)

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Private_area extends CI_Controller {
 public function __construct()
 {
  parent::__construct();
  if(!$this->session->userdata('id'))
  {
   redirect('signin');
  }
 }

 function index()
 {
  echo '<br /><br /><br /><h1 align="center">Welcome User</h1>';
  echo '<p align="center"><a href="'.base_url().'private_area/logout">Logout</a></p>';
 }

 function logout()
 {
  $data = $this->session->all_userdata();
  foreach($data as $row => $rows_value)
  {
   $this->session->unset_userdata($row);
  }
  redirect('signin');
 }
}

?>

Free Live Chat for Any Issue

Models(Signup_model.php)

<?php
class Signup_model extends CI_Model
{
 function insert($data)
 {
  $this->db->insert('members_mst', $data);
  return $this->db->insert_id();
 }

 function member_email_verify($key)
 {
  $this->db->where('member_key_verification', $key);
  $this->db->where('is_email_verified', 'no');
  $query = $this->db->get('members_mst');
  if($query->num_rows() > 0)
  {
   $data = array(
    'is_email_verified'  => 'yes'
   );
   $this->db->where('member_key_verification', $key);
   $this->db->update('members_mst', $data);
   return true;
  }
  else
  {
   return false;
  }
 }
}

?>

Models(SignIn_model.php)

<?php
class SignIn_model extends CI_Model
{
 function can_signin($email, $password)
 {
  $this->db->where('email', $email);
  $query = $this->db->get('members_mst');
  if($query->num_rows() > 0)
  {
   foreach($query->result() as $row)
   {
    if($row->is_email_verified == 'yes')
    {
     $store_password = $this->encrypt->decode($row->password);
     if($password == $store_password)
     {
      $this->session->set_userdata('id', $row->id);
     }
     else
     {
      return 'Wrong Member Password';
     }
    }
    else
    {
     return 'First verified member email address';
    }
   }
  }
  else
  {
   return 'Wrong Member Email Address';
  }
 }
}

?>

Views(signup.php)

<!DOCTYPE html>
<html>
<head>
 <title>Complete User Registration and SignIn System in Codeigniter</title>
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
</head>

<body>
 <div class="pakainfo container">
  <br />
  <h3 align="center">Codeigniter - Complete User Registration and SignIn System</h3>
<a href="https://www.pakainfo.com/" target="_blank" alt="pakainfo" title="pakainfo">Free Download Example - Pakainfo.com</a>
  <div class="panel panel-primary">
   <div class="panel-heading">Signup</div>
   <div class="panel-body">
    <form method="post" action="<?php echo base_url(); ?>signup/validation">
     <div class="gst form-group pakainfo">
      <label>Enter Member Name</label>
      <input type="text" name="member_name" class="pakainfo form-control" value="<?php echo set_value('member_name'); ?>" />
      <span class="text-danger"><?php echo form_error('member_name'); ?></span>
     </div>
     <div class="gst form-group pakainfo">
      <label>Enter Member Valid Email Address</label>
      <input type="text" name="member_email" class="pakainfo form-control" value="<?php echo set_value('member_email'); ?>" />
      <span class="text-danger"><?php echo form_error('member_email'); ?></span>
     </div>
     <div class="gst form-group pakainfo">
      <label>Enter Password</label>
      <input type="password" name="member_password" class="pakainfo form-control" value="<?php echo set_value('member_password'); ?>" />
      <span class="text-danger"><?php echo form_error('member_password'); ?></span>
     </div>
     <div class="gst form-group pakainfo">
      <input type="submit" name="signup" value="Signup" class="btn btn-info" />
     </div>
    </form>
   </div>
   <a href="https://www.pakainfo.com/" target="_blank" alt="pakainfo" title="pakainfo">Free Download Example - Pakainfo.com</a>
  </div>
 </div>
</body>
</html>

Codeigniter Views(email_verification.php)

<!DOCTYPE html>
<html>
<head>
 <title>Complete SignIn Signup Management in Codeigniter</title>
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
</head>

<body>
 <div class="container">
  <br />
  <h3 align="center">Complete SignIn Signup Management in Codeigniter</h3>
<a href="https://www.pakainfo.com/" target="_blank" alt="pakainfo" title="pakainfo">Free Download Example - Pakainfo.com</a>
  
  <?php

  echo $message;
  
  ?>
  
 </div>
</body>
</html>

Codeigniter Views(signin.php)

<!DOCTYPE html>
<html>
<head>
    <title>Complete User Registration and SignIn System in Codeigniter</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
</head>

<body>
    <div class="container">
        <br />
        <h3 align="center">Complete User Registration and SignIn System in Codeigniter</h3>
        <br />
        <div class="panel panel-default">
            <div class="panel-heading">SignIn</div>
            <div class="panel-body">
                <?php
                if($this->session->flashdata('message'))
                {
                    echo '
                    <div class="alert alert-success">
                        '.$this->session->flashdata("message").'
                    </div>
                    ';
                }
                ?>
                <form method="post" action="<?php echo base_url(); ?>signin/validation">
                    <div class="gst form-group pakainfo">
                        <label>Enter Member Email Address</label>
                        <input type="text" name="member_email" class="pakainfo form-control" value="<?php echo set_value('member_email'); ?>" />
                        <span class="text-danger"><?php echo form_error('member_email'); ?></span>
                    </div>
                    <div class="gst form-group pakainfo">
                        <label>Enter Member Password</label>
                        <input type="password" name="member_password" class="pakainfo form-control" value="<?php echo set_value('member_password'); ?>" />
                        <span class="text-danger"><?php echo form_error('member_password'); ?></span>
                    </div>
                    <div class="gst form-group pakainfo">
                        <input type="submit" name="signin" value="SignIn" class="btn btn-info" /><a href="<?php echo base_url(); ?>signup">Signup</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
	<a href="https://www.pakainfo.com/" target="_blank" alt="pakainfo" title="pakainfo">Free Download Example - Pakainfo.com</a>
</body>
</html>

Angular 6 CRUD Operations Application Tutorials

Read :

  • Technology
  • Google Adsense
  • Programming
Also Read This πŸ‘‰   what is solid principles? and solid 5 principles c#

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Complete User Registration system using Codeigniter 3.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Pakainfo
Pakainfo

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I’m a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Also Read This πŸ‘‰   VueJS setTimeout() Function Examples

Related posts:

  1. CodeIgniter Simple User Registration and Login System
  2. CodeIgniter Login Registration Example Tutorial From Scratch
  3. Laravel 7/6 disable registration example
  4. Create a Registration and Login System with PHP and MySQL
  5. How to change password in CodeIgniter framework?
  6. Simple CodeIgniter 3 login MySQL Database
  7. registration and signin form in php and mysql with validation
  8. jQuery Ajax Secure Login Registration System in PHP and MySQL
Also Read This πŸ‘‰   ng-model Directive using Angular Example
codeigniter 3 logincodeigniter login and access management systemcodeigniter login and registration githubcodeigniter login and registration source codecodeigniter login and registration with sessioncodeigniter simple login systemComplete User Registration system using Codeigniter 3Complete User Registration system using PHP and MySQL databasehow to create login form in codeigniteruser registration form in codeigniter

Post navigation

Previous Post:PHP Multiple Authentication using Laravel 5.7 Middleware
Next Post:Ckeditor required field validation using Jquery

Search

Write For Us

We’re accepting well-written informative guest posts and this is a great opportunity to collaborate.
Submit a guest post to [email protected]
Contact Us

Freelance web developer

Do you want to build a modern, lightweight, responsive website quickly?
Need a Website Or Web Application Contact : [email protected]
Note: Paid Service
Contact Me

Categories

3movierulz (58) Ajax (464) AngularJS (377) ASP.NET (61) Bollywood (102) Codeigniter (175) CSS (98) Earn Money (61) Education (56) Entertainment (123) fullform (82) Google Adsense (62) Highcharts (77) Hollywood (103) JavaScript (1356) Jobs (40) jQuery (1422) Laravel (1087) LifeStyle (51) movierulz4 (57) Mysql (1029) Mysqli (890) Node.js (39) php (2117) Programming (2330) Python (96) ReactJS (37) Software (137) Software (83) Stories (95) tamilrockers (98) Tamilrockers kannada (58) Tamilrockers telugu (57) Tech (133) Technology (2379) Tips and Tricks (113) Tools (177) Top10 (399) Trading (74) Trending (63) VueJs (250) Web Technology (97) webtools (180) wordpress (166) World (219)

Advertise With Us

Increase visibility and sales with advertising. Let us promote you online.
Click Here

A To Z Full Forms

Access a complete full forms list with the meaning, definition, and example of the acronym or abbreviation.
Click Here

  • Home
  • About Us
  • Terms And Conditions
  • Write For Us
  • Advertise
  • Contact Us
  • Youtube Tag Extractor
  • Guest Posting Sites
  • Increase Domain Authority
  • Social Media Marketing
  • Freelance web developer
  • Tools
Pakainfo 9-OLD, Ganesh Sco, Kothariya Ring Road, Chokadi, Rajkot - 360002 India
E-mail : [email protected]
Pakainfo

Β© 2022 Pakainfo. All rights reserved.

Top
Subscribe On YouTube : Download Source Code
We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype YouTube Tag Extractor