CodeIgniter Simple User Registration and Login System
In this Post We Will Explain About is CodeIgniter Simple User Registration and Login System With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Make Simple Login Form in CodeIgniter With Sessions Example
In this post we will show you Best way to implement CodeIgniter Simple Login Form With Sessions, hear for How to Create Login Form in CodeIgniter, MySQL and Twitter Bootstrap with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.
autoload.php
config.php
Table: students
-- -- Table structure for table `students` -- CREATE TABLE IF NOT EXISTS `students` ( `id` int(11) NOT NULL AUTO_INCREMENT, `studentname` varchar(250) NOT NULL, `password` varchar(250) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -- Dumping data for table `students` -- INSERT INTO `students` (`id`, `studentname`, `password`) VALUES (1, 'jaydeepGondaliya', 'live24udot@#csom');
Controllers – main.php
load->view("login", $data); } function auth_validation_login() { $this->load->library('form_validation'); $this->form_validation->set_rules('studentname', 'StudentName', 'required'); $this->form_validation->set_rules('password', 'Password', 'required'); if($this->form_validation->run()) { //live boolean value true $studentname = $this->input->post('studentname'); $password = $this->input->post('password'); //codeigniter model function $this->load->model('main_model'); if($this->main_model->stud_auth($studentname, $password)) { $session_data = array( 'studentname' => $studentname ); $this->session->set_userdata($session_data); redirect(base_url() . 'main/enter'); } else { $this->session->set_flashdata('error', 'Invalid StudentName and Password'); redirect(base_url() . 'main/login'); } } else { //boolean value false $this->login(); } } function enter(){ if($this->session->userdata('studentname') != '') { echo 'Welcome - '.$this->session->userdata('studentname').'
'; echo ''; } else { redirect(base_url() . 'main/login'); } } function logout() { $this->session->unset_userdata('studentname'); redirect(base_url() . 'main/login'); } }
Models – main_model.php
db->where('studentname', $studentname); $this->db->where('password', $password); $query = $this->db->get('students'); //SELECT * FROM students WHERE studentname = '$studentname' AND password = '$password' if($query->num_rows() > 0) { return true; } else { return false; } } }
Views – login.php
Pakainfo.com |
<form method="post" action="main/auth_validation_login"><?php echo ''; ?>
You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example
I hope you have Got What is php – Login system with session using CodeIgniter And how it works.I would Like to have FeedBack From My Blog(Pakainfo.com) readers.Your Valuable FeedBack,Any Question,or any Comments about This Article(Pakainfo.com) Are Most Always Welcome.