Skip to content
pakainfo

Pakainfo

Web Development & Good Online education

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

Simple CodeIgniter 3 login MySQL Database

January 13, 2019 Pakainfo Programming, Codeigniter, Mysqli, php Leave a comment

Today, We want to share with you Simple CodeIgniter 3 login MySQL Database Source Code.In this post we will show you PHP CodeIgniter 3 Login Form with Sessions, hear for Complete User Authentication System in CodeIgniter 3 we will give you demo and example for implement.In this post, we will learn about Login Signup page in CodeIgniter 3 with MySQL Database Source Code with an example.

Simple CodeIgniter 3 login MySQL Database Source Code

Contents

  • Simple CodeIgniter 3 login MySQL Database Source Code
    • CodeIgniter 3 Connect SQL Database
    • Step 1 Download / install CodeIgniter 3.
    • Step 3 Config codeigniter 3 Database
    • Step 4 create Codeigniter 3 controller
    • Step 5create a login form in Codeigniter 3
    • Step 6 Run Project
    • Read
    • Summary
    • Related posts

There are the Following The simple About Simple CodeIgniter 3 login MySQL Database Source Code Full Information With Example and source code.

As I will cover this Post with live Working example to develop CodeIgniter Simple Login Form With Sessions, so the codeigniter 3.1.9 documentation for this example is following below.

Also Read This 👉   CodeIgniter Simple User Registration and Login System

CodeIgniter 3 Connect SQL Database

Here are the step by step to create a simple login system using PHP Based CodeIgniter 3

DATABASE Simple SQL TABLE

create DATABASE `member_mst`;
 
CREATE TABLE IF NOT EXISTS `members` (
  `member_id` int(11) NOT NULL AUTO_INCREMENT,
  `member_fname` varchar(255) NOT NULL,
  `member_lname` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`member_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2;
--
-- Dumping data for table `members`
--
INSERT INTO `members` (`member_id`, `member_fname`, `member_lname`, `email`, `password`, `created_at`) VALUES
(1, 'Pakainfo', 'PHP', '[email protected]', '$2y$10$8mVSGv/bIGgcvCikXBPfTu7HfXMl3jqfiirtQGyRwV5bvOzNGmmLG', '2019-12-17 18:09:10');

Step 1: Download / install CodeIgniter 3.

set Config Files

application/config/config.php

$config['base_url'] = 'http://localhost:8080/';
$config['sess_save_path'] = sys_get_temp_dir();

Step 3: Config codeigniter 3 Database

Simple this step to Connect Your Database using codeigniter 3

application/config/database.php

$db['default'] = array(
    'dsn'    => '',
    'hostname' => 'localhost',
    'membername' => 'root',
    'password' => '',
    'database' => 'member_mst',
    'dbdriver' => 'mysqli',
         ....
        ......
    'save_queries' => TRUE
);

Step 4: create Codeigniter 3 controller

create a codeigniter 3 controller file called Member.php

application/controllers

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
 
class Member extends CI_Controller {
 
    public function __construct() {
        parent::__construct();
        $this->load->helper(array('form', 'url'));
        $this->load->library(['form_validation','session']);
        $this->load->database();
    }
 
    public function login() {
 
        $this->form_validation->set_rules('email', 'Email', 'required');
        $this->form_validation->set_rules('password', 'Password', 'required');
 
        if ($this->form_validation->run() == FALSE) {
            $this->load->view('login_view');
        } else {
 
            $email = $this->input->post('email');
            $password = $this->input->post('password');
 
            $member = $this->db->get_where('members',['email' => $email])->row();
            
            if(!$member) {
                $this->session->set_flashdata('login_error', 'Please check your email or password and try again.', 300);
                redirect(uri_string());
            }
 
    
            if(!password_verify($password,$member->password)) {
                $this->session->set_flashdata('login_error', 'Please check your email or password and try again.', 300);
                redirect(uri_string());
            }
 
             $data = array(
                    'member_id' => $member->member_id,
                    'member_fname' => $member->member_fname,
                    'member_lname' => $member->member_lname,
                    'email' => $member->email,
                    );
 
                
            $this->session->set_memberdata($data);
 
            //simple CI_Controller 3 redirect('/'); // redirect to main auth home
            echo 'Login success!'; exit;
            
        }        
    }
 
    public function logout(){
        $this->session->sess_destroy();
        redirect('member/login');
    }
 
}

Step 5:create a login form in Codeigniter 3

login_form.php

Also Read This 👉   Codeigniter Project Directory Structure

application/views

 <div class="container pakainfo">
 
        <?php echo form_open('member/login'); ?>
 
        <div class="form-group pakainfo">
            <label for="email">Email address</label>
            <input type="email" class="form-control pakainfo" value="<?php echo set_value('email'); ?>" id="email" name="email" aria-describedby="emailHelp" placeholder="Enter Your Correct email Address">
            <?php echo form_error('email'); ?>
        </div>
        <div class="form-group pakainfo">
            <label for="password">Password</label>
            <input type="password" class="form-control pakainfo" name="password" id="Inputdatapwd" placeholder="Eneter Your Strong Password">
            <?php echo form_error('password'); ?>
        </div>
        <button type="submit" class="btn btn-success">Sign In</button>
        <?php echo $this->session->flashdata('login_error'); ?>
        
        <?php form_close(); ?>
    </div>

Step 6: Run Project

That’s it. Now head over your browser Like Mozila, Chrome..

Also Read This 👉   Renaming file while uploading Laravel

http://localhost:8080/member/login 

Angular 6 CRUD Operations Application Tutorials

Read :

  • Technology
  • Google Adsense
  • Programming

Summary

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

I hope you get an idea about Simple CodeIgniter 3 login MySQL Database Source Code.
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.

Related posts:

  1. CodeIgniter Simple User Registration and Login System
  2. how to make a login page in html with database?
  3. Create a Registration and Login System with PHP and MySQL
  4. How to upload image in codeigniter mysql database and display?
  5. PHP login logout script with session Example
  6. jQuery Ajax Secure Login Registration System in PHP and MySQL
  7. insert and display data from database in codeigniter
  8. PHP Codeigniter Tutorial: CRUD Example App with Bootstrap 4 and MySQL Database
codeigniter 3 loginCodeIgniter 3 Login ExampleCodeIgniter 3 MySQL Logincodeigniter 3 tutorialcodeigniter 3.1.8 tutorialcodeigniter 3.1.9 documentationcodeigniter 4codeigniter 4 tutorialcodeigniter downloadhow to install codeigniterhow to use codeigniter

Post navigation

Previous Post:MySql comma separated column join using PHP Laravel
Next Post:PHP Merge Multiple PDF Files with Ghostscript

Advertise With Us

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

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 (64) Ajax (464) AngularJS (377) ASP.NET (61) Bio (109) Bollywood (108) Codeigniter (175) CSS (98) Earn Money (69) Education (61) Entertainment (130) fullform (86) Google Adsense (63) Highcharts (77) History (40) Hollywood (109) JavaScript (1357) Jobs (42) jQuery (1423) Laravel (1088) LifeStyle (53) movierulz4 (63) Mysql (1029) Mysqli (890) php (2121) Programming (2332) Python (97) Software (166) Software (88) Stories (98) tamilrockers (104) Tamilrockers kannada (64) Tamilrockers telugu (61) Tech (142) Technology (2392) Tips and Tricks (119) Tools (203) Top10 (478) Trading (90) Trending (71) VueJs (250) Web Technology (105) webtools (191) wordpress (166) World (322)

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
  • Info Grepper
  • 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

© 2023 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 Guest Posting Sites