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
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.
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
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
application/views
session->flashdata('login_error'); ?>
Step 6: Run Project
That’s it. Now head over your browser Like Mozila, Chrome..
http://localhost:8080/member/login
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 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.