Complete User Registration system using Codeigniter 3 – Programming

Complete User Registration system using Codeigniter 3 – Programming

In this post we will give you information about Complete User Registration system using Codeigniter 3 – Programming. Hear we will give you detail about Complete User Registration system using Codeigniter 3 – ProgrammingAnd how to use it also give you demo for it if it is necessary.

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

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("rn");
    $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)

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

<?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');
 }
}

?>

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 >
  <br />
  <h3 align="center">Codeigniter - Complete User Registration and SignIn System</h3>
<a href="https://onlinecode.org/" target="_blank" alt="onlinecode" title="onlinecode">Free Download Example - onlinecode</a>
  <div >
   <div >Signup</div>
   <div >
    <form method="post" action="<?php echo base_url(); ?>signup/validation">
     <div >
      <label>Enter Member Name</label>
      <input type="text" name="member_name"  value="<?php echo set_value('member_name'); ?>" />
      <span ><?php echo form_error('member_name'); ?></span>
     </div>
     <div >
      <label>Enter Member Valid Email Address</label>
      <input type="text" name="member_email"  value="<?php echo set_value('member_email'); ?>" />
      <span ><?php echo form_error('member_email'); ?></span>
     </div>
     <div >
      <label>Enter Password</label>
      <input type="password" name="member_password"  value="<?php echo set_value('member_password'); ?>" />
      <span ><?php echo form_error('member_password'); ?></span>
     </div>
     <div >
      <input type="submit" name="signup" value="Signup"  />
     </div>
    </form>
   </div>
   <a href="https://onlinecode.org/" target="_blank" alt="onlinecode" title="onlinecode">Free Download Example - onlinecode</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 >
  <br />
  <h3 align="center">Complete SignIn Signup Management in Codeigniter</h3>
<a href="https://onlinecode.org/" target="_blank" alt="onlinecode" title="onlinecode">Free Download Example - onlinecode</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 >
        <br />
        <h3 align="center">Complete User Registration and SignIn System in Codeigniter</h3>
        <br />
        <div >
            <div >SignIn</div>
            <div >
                <?php
                if($this->session->flashdata('message'))
                {
                    echo '
                    <div >
                        '.$this->session->flashdata("message").'
                    </div>
                    ';
                }
                ?>
                <form method="post" action="<?php echo base_url(); ?>signin/validation">
                    <div >
                        <label>Enter Member Email Address</label>
                        <input type="text" name="member_email"  value="<?php echo set_value('member_email'); ?>" />
                        <span ><?php echo form_error('member_email'); ?></span>
                    </div>
                    <div >
                        <label>Enter Member Password</label>
                        <input type="password" name="member_password"  value="<?php echo set_value('member_password'); ?>" />
                        <span ><?php echo form_error('member_password'); ?></span>
                    </div>
                    <div >
                        <input type="submit" name="signin" value="SignIn"  /><a href="<?php echo base_url(); ?>signup">Signup</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
	<a href="https://onlinecode.org/" target="_blank" alt="onlinecode" title="onlinecode">Free Download Example - onlinecode</a>
</body>
</html>
Angular 6 CRUD Operations Application Tutorials

Read :

Another must read:  Get last inserted record ID mySQL using PHP

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 onlinecode 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.

Hope this code and post will helped you for implement Complete User Registration system using Codeigniter 3 – Programming. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

46  +    =  56

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US