Today, We want to share with you CodeIgniter Login Registration System using MySQL Bootstrap.In this post we will show you codeigniter login and registration with session, hear for login form in codeigniter with validation we will give you demo and example for implement.In this post, we will learn about login form in codeigniter with validation and session with an example.
CodeIgniter Login Registration System using MySQL Bootstrap
There are the Following The simple About CodeIgniter Login Registration System using MySQL Bootstrap 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 codeigniter login and registration with registration form in codeigniter for this example is following below.
- CodeIgniter Create Database and Tables
- Add Mysql Sample Data
- CodeIgniter Setting
- Create CodeIgniter Controller
- Create Model in codeigniter
- Create Registration Form
- Create SignIn Form
- View Profile and Add information
CodeIgniter Login Registration Project Folder Structure
CodeIgniter Login Registration Script
codeigniter login and registration with session
This is where I will make a simple HTML form and PHP CodeIgniter server side source code for our web application. To make the forms simply all souce code copy and write it into your any text editor Like Notepad++, then save file it as codeigniter login system.
Step 1 – CodeIgniter Create Database and Tables
Table structure for table `member
CREATE TABLE `member` ( `member_id` int(11) NOT NULL, `member_name` varchar(50) NOT NULL, `member_email` varchar(50) NOT NULL, `member_password` varchar(50) NOT NULL, `member_age` int(11) NOT NULL, `member_mobile` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Step 2 – Add Mysql Sample Data
Dumping data for table `member`
//CodeIgniter Login Registration Example Tutorial From Scratch INSERT INTO `member` (`member_id`, `member_name`, `member_email`, `member_password`, `member_age`, `member_mobile`) VALUES (1, 'Jaydeep', '[email protected]', '9898', 23, 3398256933), (2, 'Jaydeep', '[email protected]', '9898', 23, 2142578547), (3, 'Krunal', '[email protected]', '9898', 32, 2245875343), (4, 'ankit', '[email protected]', '202cb962ac55656832Sddb07152d234b70', 23, 5685656585);
Step 3 – CodeIgniter Setting
Some CodeIgniter Setting for CodeIgniter Login Registration System
application>config>config.php
Remove Index.php from CodeIgniter.
application>config>autoload.php
$autoload['libraries'] = array(); //replace it with this code $autoload['libraries'] = array('session','database');
application>config>database.php
application>config>routes.php
$route['default_controller'] = 'member';
Step 4 – Member Controller
application>>controller >> named Member.php
load->helper('url'); $this->load->model('member_model'); $this->load->library('session'); } } ?>
4.2 –> codeigniter Create a new Index method for Member Controller
public function index() { $this->load->view("signup.php"); }
4.3 –> codeigniter signup_member()
public function signup_member(){ $member=array( 'member_name'=>$this->input->post('member_name'), 'member_email'=>$this->input->post('member_email'), 'member_password'=>md5($this->input->post('member_password')), 'member_age'=>$this->input->post('member_age'), 'member_mobile'=>$this->input->post('member_mobile') ); print_r($member); $email_check=$this->member_model->email_check($member['member_email']); if($email_check){ $this->member_model->signup_member($member); $this->session->set_flashdata('preview_success_msg', 'SignUped successfully.Now login to your account.'); redirect('member/signin_view'); } else{ $this->session->set_flashdata('preview_err_msg', 'Error occured,Try again.'); redirect('member'); } }
4.4 –> simple signin_view()
public function signin_view(){ $this->load->view("login.php"); }
4.5 –> codeigniter login_member()
function login_member(){ $member_login=array( 'member_email'=>$this->input->post('member_email'), 'member_password'=>md5($this->input->post('member_password')) ); $data=$this->member_model->login_member($member_login['member_email'],$member_login['member_password']); if($data) { $this->session->set_memberdata('member_id',$data['member_id']); $this->session->set_memberdata('member_email',$data['member_email']); $this->session->set_memberdata('member_name',$data['member_name']); $this->session->set_memberdata('member_age',$data['member_age']); $this->session->set_memberdata('member_mobile',$data['member_mobile']); $this->load->view('member_profile.php'); } else{ $this->session->set_flashdata('preview_err_msg', 'Error occured,Try again.'); $this->load->view("login.php"); } }
4.6 –> CodeIgniter member_profile()
function member_profile(){ $this->load->view('member_profile.php'); }
4.7 –> codeigniter member_logout()
public function member_logout(){ $this->session->sess_destroy(); redirect('member/signin_view', 'refresh'); }
4.8 –> codeigniter Member Controller
load->helper('url'); $this->load->model('member_model'); $this->load->library('session'); } public function index() { $this->load->view("signup.php"); } public function signup_member(){ $member=array( 'member_name'=>$this->input->post('member_name'), 'member_email'=>$this->input->post('member_email'), 'member_password'=>md5($this->input->post('member_password')), 'member_age'=>$this->input->post('member_age'), 'member_mobile'=>$this->input->post('member_mobile') ); print_r($member); $email_check=$this->member_model->email_check($member['member_email']); if($email_check){ $this->member_model->signup_member($member); $this->session->set_flashdata('preview_success_msg', 'SignUped successfully.Now login to your account.'); redirect('member/signin_view'); } else{ $this->session->set_flashdata('preview_err_msg', 'Error occured,Try again.'); redirect('member'); } } public function signin_view(){ $this->load->view("login.php"); } function login_member(){ $member_login=array( 'member_email'=>$this->input->post('member_email'), 'member_password'=>md5($this->input->post('member_password')) ); $data=$this->member_model->login_member($member_login['member_email'],$member_login['member_password']); if($data) { $this->session->set_memberdata('member_id',$data['member_id']); $this->session->set_memberdata('member_email',$data['member_email']); $this->session->set_memberdata('member_name',$data['member_name']); $this->session->set_memberdata('member_age',$data['member_age']); $this->session->set_memberdata('member_mobile',$data['member_mobile']); $this->load->view('member_profile.php'); } else{ $this->session->set_flashdata('preview_err_msg', 'Error occured,Try again.'); $this->load->view("login.php"); } } function member_profile(){ $this->load->view('member_profile.php'); } public function member_logout(){ $this->session->sess_destroy(); redirect('member/signin_view', 'refresh'); } } ?>
Step 5 – Create CodeIgniter Member Model
5.1 -> application>>model folder >> Member_model.php
5.2 –> codeigniter signup_member()
public function signup_member($member){ $this->db->insert('member', $member); }
5.3 –> codeigniter login_member()
public function login_member($email,$pass){ $this->db->select('*'); $this->db->from('member'); $this->db->where('member_email',$email); $this->db->where('member_password',$pass); if($query=$this->db->get()) { return $query->row_array(); } else{ return false; } }
5.4 -> codeigniter email_check Functions
public function email_check($email){ $this->db->select('*'); $this->db->from('member'); $this->db->where('member_email',$email); $query=$this->db->get(); if($query->num_rows()>0){ return false; }else{ return true; } }
5.5 -> Member_Model Source code
db->insert('member', $member); } public function login_member($email,$pass){ $this->db->select('*'); $this->db->from('member'); $this->db->where('member_email',$email); $this->db->where('member_password',$pass); if($query=$this->db->get()) { return $query->row_array(); } else{ return false; } } public function email_check($email){ $this->db->select('*'); $this->db->from('member'); $this->db->where('member_email',$email); $query=$this->db->get(); if($query->num_rows()>0){ return false; }else{ return true; } } } ?>
Step 6- Make A SignUp Form (HTML View)
Create a simple SignUp.php File
SignUp -CodeIgniter SignIn Registration Registration
session->flashdata('preview_err_msg'); if($preview_err_msg){ echo $preview_err_msg; } ?>Already signuped ?
SignIn here
Step 7 : Create SignIn Form
Create a simple SignIn.php(View ) side Source code
SignIn-CodeIgniter SignIn Registration session->flashdata('preview_success_msg'); $preview_err_msg= $this->session->flashdata('preview_err_msg'); if($preview_success_msg){ ?>SignIn
Not signuped ?
SignUp here
Step 8 : Member_profile view Full Source code
Create a Simple Member_profile.php
session->memberdata('member_id'); if(!$member_id){ redirect('member/signin_view'); } ?>Member Profile Dashboard - PHP CodeIgniter SignIn Registration System
Angular 6 CRUD Operations Application Tutorials
Read :
Summary
You can also read about AngularJS, ASP.NET, VueJs, PHP.
I hope you get an idea about CodeIgniter Login Registration System using MySQL Bootstrap.
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.