Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function do_login() {
- if ($this->session->userdata('is_admin_login')) {
- redirect('admin/home/dashboard');
- } else {
- $user = $_POST['username'];
- $password = $_POST['password'];
- $this->form_validation->set_rules('username', 'Username', 'required');
- $this->form_validation->set_rules('password', 'Password', 'required');
- if ($this->form_validation->run() == FALSE) {
- $this->load->view('admin/vwLogin');
- } else {
- $salt = '5&JDDlwz%Rwh!t2Yg-Igae@QxPzFTSId';
- $enc_pass = md5($salt.$password);
- $sql = "SELECT * FROM tbl_admin_users WHERE username = ? AND password = ?";
- $val = $this->db->query($sql,array($user ,$enc_pass ));
- if ($val->num_rows) {
- foreach ($val->result_array() as $recs => $res) {
- $sess_array = array(
- 'id' => $res['id'],
- 'username' => $res['username'],
- 'email' => $res['email'],
- 'is_admin_login' => true,
- 'user_type' => $res['user_type']
- );
- $this->session->set_userdata($sess_array);
- }
- redirect('admin/dashboard');
- } else {
- $err['error'] = '<strong>Access Denied</strong> Invalid Username/Password';
- $this->load->view('admin/vwLogin', $err);
- }
- }
- }
- }
- if (!defined('BASEPATH'))
- exit('No direct script access allowed');
- class Dashboard extends CI_Controller {
- public function __construct() {
- parent::__construct();
- $this->load->library('form_validation');
- dump_exit($this->session->userdata);
- if (!$this->session->userdata('is_admin_login')) {
- redirect('admin/home');
- }
- }
- public function index() {
- $arr['page']='dash';
- $this->load->view('admin/vwDashboard',$arr);
- }
- }
- $autoload['libraries'] = array('database', 'session', 'form_validation');
- $autoload['helper'] = array('url', 'form', 'dump');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement