i have login form like this

log in to the application, it shows menu like this

it went fine until i click some menu, then it shows

here is the controller of the link that i clicked
i thought keuangan was already on the menu, but why does the keuangan not appear when i click some link of the menu ?
function index()
{
$data['title'] = 'QB Cash Advance Settlement';
$this->load->view('menu',$data);
$this->load->view('v/vcas');
}
here is the c_menu controller
function index()
{
$data['title'] = "QB Dashboard";
$data['jabatan'] = "Keuangan";
$this->load->view('menu',$data);
$this->load->view('body');
}
here is the menu_view
<div id ="user">Selamat datang, <?php echo $jabatan; ?></div>
the login controller
function login()
{
$username = $this->input->post('username');
$jabatan = $this->input->post('jabatan');
$this->form_validation->set_rules('username','Username','alpha_numeric|trim|required|xss_clean');
$this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean|callback_check_database');
if($this->form_validation->run() == FALSE)
{
$this->load->view('login');
}
else
{
if($jabatan == 'keuangan')
{
redirect('c_menu','refresh');
}
else if ($jabatan == 'hd')
{
echo $jabatan;
}
else
{
echo $jabatan;
}
}
do i need to declare $data['title'] = 'keuangan' in every controller/index ?
The data you bind into the view will not persist. So it’s there when you load the menu the first time because you set it in the controller here:
But then when you click on the link it goes to a different controller.
$data['jabatan']is not set in this controller before binding$datainto the view, so that’s why it is undefined.