Do not redirect to the link

1

Good morning, I have the following problem, when I click on the menu link, it does not redirect me to the view I want, but it redirects me to login .... PD: When loading the project loads the login view, and you have to log in to access the index. I do this with the following driver:

<?php

class cLogin extends CI_Controller{

    function __construct(){
        parent::__construct();
        $this->load->model('mLogin');   
    }

    public function index(){
        $data['mensaje'] = '';
        $this->load->view('vLogin',$data);
    }

    public function ingresar(){

        $nombre_usu= $this->input->post('nombre_usu');
        $pass_usu= $this->input->post('pass_usu');

        $res= $this->mLogin->ingresar($nombre_usu,$pass_usu);

        if ($res ==1) {
            $this->load->view('layouts/header.php');
            $this->load->view('layouts/menu.php');
            $this->load->view('usuarios/vIndex.php');
            $this->load->view('layouts/footer.php');
        } else {
            $data['mensaje'] = "Usuario o contraseña Incorrecta";
            $this->load->view('vLogin',$data);
        }

    }
 }

 ?>

The link of the Menu

 <li class="active">
     <a href="<?php echo base_url();?>cCalendar">
         <i class="fa fa-circle-o"></i> 
         Consultar Horarios
     </a>
 </li>

This is the controller

<?php

class cCalendar extends  CI_Controller{

    function __construct(){
        parent::__construct();
        $this->load->model('mCalendar');
    }

    public function index(){
        $this->load->view('layouts/header.php');
        $this->load->view('layouts/menu.php');
        $this->load->view('usuarios/vCalendar.php');
        $this->load->view('layouts/footer.php'); 
    }
}

?>
    
asked by CristianOx21 04.09.2017 в 16:31
source

1 answer

1

By what you see in your link you are simply redirecting to base_url() , which will take you directly to the function index of the default controller that you have put in the variable $route['default_controller'] of the file ./application/config/routes.php , so you simply have to change your link in the following way:

<li class="active">
    <a href="<?= base_url('index.php/cCalendar'); ?>">
        <i class="fa fa-circle-o"></i>
        Consultar Horarios
    </a>
</li>

You must pass an argument to the function base_url() which in this case is the name of the controller you want to access

The <?= base_url(); ?> is simply translated as <?php echo base_url(); ?>

    
answered by 04.09.2017 / 16:57
source