I am new to code igniter framework. I am having issue to call view from controller.
I have 3 three controllers in my application/controllers/ folder
employee.php, home.php and dashboard.php
and 5 views in my views/template/ folder
header.php, footer.php, sidebar.php, template.php and topmenu.php
and 3 views in my main views folder
addEmployee.php, home.php and dashboard.php
I am able to hit the home and dashboard controller, but unable to hit the employee controller to load addEmployee view.
this is my addEmployee.php view
<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>
<title>Add Employee</title>
<div class="main-content">
<?php include 'template/topmenu.php' ?>
<!-- PAGE CODE STARTS BELOW FROM HERE -->
</div>
employee.php controller
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Employee extends CI_Controller {
public function __construct() {
parent::__construct();
$this -> load -> model('employee_model');
}
public function index() {
$data['header'] = 'template/header';
$data['sidebar'] = 'template/sidebar';
$data['main_content'] = 'addEmployee';
$data['footer'] = 'template/footer';
$this->load->view('template/template',$data);
}
function functionToTestgetAndSaveEmployeeDetailsResult() {
$result = $this -> getAndSaveEmployeeDetails();
print_r($result);
}
}
?>
template/template.php view
<?php defined( 'BASEPATH') OR exit( 'No direct script access allowed'); ?>
<?php
$this->load->view($header);
$this->load->view($sidebar);
$this->load->view($main_content);
$this->load->view($footer);
?>
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
config/config.php
$config['base_url'] = 'http://localhost:8050/test/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
I am using this url to access the views
http://localhost:8050/test/ for home
http://localhost:8050/test/dashbaord for dashbaord
http://localhost:8050/test/addEmployee for addEmployee
home and dashboard views work by this but addEmployee doesn't.
I have also tried these url but no luck
http://localhost:8050/test/employee/addEmployee
http://localhost:8050/test/index.php/addEmployee
http://localhost:8050/test/index.php/employee/addEmployee
Any idea, what is wrong with this addEmployee view? or any link ?