McGansWebsite/admin/application/controllers/Welcome.php
dotwingssoftware 6515996f87 20230121
Role, Employee, Department, Degree, Semester, Subject, Faculty Edit Completed
2023-01-21 19:11:47 +05:30

64 lines
1.5 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('Common_model');
$this->load->model('Project_model');
}
public function index()
{
$this->load->view('login');
}
public function dashboard()
{
$data['project']=$this->Project_model->totalProjects();
$data['student']=$this->Project_model->totalStudents();
$data['subject']=$this->Project_model->totalSubject();
$data['faculty']=$this->Project_model->totalFaculties();
$data['projectList']=$this->Project_model->recentlyAddedProject();
$this->load->view('dashboard',$data);
}
public function login()
{
//echo "dsds";exit;
$username=$this->input->post('username');
$password=$this->input->post('password');
$check=$this->Common_model->get_login_detail($username,$password);
//echo $this->db->last_query();exit;
if($check->num_rows()>0)
{
$ch =$check->row();
$this->session->set_userdata('username',$ch->username);
$this->session->set_userdata('id',$ch->id);
$this->session->set_userdata('suc',' Successfully Logged in..!');
redirect('dashboard');
}
else
{
$this->session->set_userdata('err','The username or password is incorrect.');
redirect('');
}
}
public function logout()
{
$admin_id=$this->session->userdata('id');
$data = array('id' => '', 'username' => '');
$this->session->unset_userdata($data);
$this->session->sess_destroy();
redirect('');
}
}