Line | |
---|
1 | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
---|
2 |
|
---|
3 | class Home extends MX_Controller
|
---|
4 | {
|
---|
5 | public function __construct()
|
---|
6 | {
|
---|
7 | parent::__construct();
|
---|
8 | $this->load->helper('cookie');
|
---|
9 | }
|
---|
10 |
|
---|
11 | public function index ()
|
---|
12 | {
|
---|
13 |
|
---|
14 | $admin_info = $this->session->userdata('adminInfo');
|
---|
15 | if ($admin_info)
|
---|
16 | {
|
---|
17 | $this->load->view('index');
|
---|
18 | }else
|
---|
19 | {
|
---|
20 | $this->load->view ( 'login');
|
---|
21 | }
|
---|
22 | }
|
---|
23 |
|
---|
24 | public function login()
|
---|
25 | {
|
---|
26 |
|
---|
27 | $username = $this->input->post('user_admin');
|
---|
28 | $password = $this->input->post('password');
|
---|
29 |
|
---|
30 | $this->load->model(array('admin_model'));
|
---|
31 | $data = $this->admin_model->check_login($username, $password);
|
---|
32 | if ($data == null)
|
---|
33 | {
|
---|
34 | $this->session->set_flashdata('login_error', TRUE);
|
---|
35 | redirect("/admin/home");
|
---|
36 | }
|
---|
37 | else
|
---|
38 | {
|
---|
39 | $admindata = array('user_admin' => $username, "logined_in" => TRUE);
|
---|
40 | $this->session->set_userdata('adminInfo', $admindata);
|
---|
41 | redirect("/admin/home");
|
---|
42 | }
|
---|
43 | }
|
---|
44 |
|
---|
45 | public function logout()
|
---|
46 | {
|
---|
47 | $this->session->sess_destroy();
|
---|
48 | redirect("/admin/home");
|
---|
49 | }
|
---|
50 |
|
---|
51 | public function user_profile()
|
---|
52 | {
|
---|
53 | $admin_info = $this->session->userdata('adminInfo');
|
---|
54 | if($admin_info)
|
---|
55 | {
|
---|
56 | $this->load->view('user_profile');
|
---|
57 | }else
|
---|
58 | {
|
---|
59 | redirect("/admin/home");
|
---|
60 | }
|
---|
61 | }
|
---|
62 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.