Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
- class Login extends CI_Controller {
- public function index() { // Default method for this controller
- page();
- }
- public function page()
- {
- $this->load->helper('url');
- $this->load->helper('html');
- $this->load->library('session');
- $error = '';
- if ($this->input->post('submit')) {
- $error = $this->userVerify();
- }
- if ($this->session->userdata('logged_in') === NULL){
- $title = 'Northwind Login';
- $data = array('title' => $title,
- 'error' => $error);
- $data['content'] = $this->load->view(
- 'login/loginPage',
- $data, TRUE);
- $this->load->view('templates/master', $data);
- } else {
- $title = 'Northwind Login Success';
- $data = array('title' => $title);
- $data['content'] = $this->load->view(
- 'login/successPage',
- $data, TRUE);
- $this->load->view('templates/master', $data);
- }
- }
- private function userVerify() {
- $this->load->model('userbase');
- $username = $this->input->post('username');
- $password = $this->input->post('password');
- $message = '';
- try {
- $result = $this->userbase->read($username, $password);
- $this->session->set_userdata('logged_in', $result);
- } catch (Exception $e) {
- $message = $e->getMessage();
- }
- return $message;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement