Welcome Guest, Not a member yet? Register   Sign In
Codeigniter custom route and parameters passed via url.
#1

Hello guys,
I have a problem with parameter passed to controller function:

PHP Code:
<?php

class App extends CI_Controller {

    public function 
__construct() {

         
parent::__construct();

    }

    public function 
login($status) {

         switch(
$status){
              case 
'err_not_allowed':
                   
$message 'You have to login first in order to access member area.';
                   break;
         }

         
$data = array(

              
'alert' => TRUE,
              
'class' => 'alert-danger',
              
'message' => $message

         
);

         
$this->load->view('header');
         
$this->load->view('navbar');
         
$this->load->view('login',$data);
         
$this->load->view('footer');

    }

}


?>

Now in routes.php I have following:

PHP Code:
$route['login'] = 'app/login';
$route['login/(:any)] = 'app/login/$1'; 

The problem is that when I will visit 'app/login/err_not_allowed' the $data array is filled properly with values but when i visit 'login/err_not_allowed' the array is empty and i get error that variable doesn't exist and is undefined.
Reply
#2

Your missing the closing quote on the last route.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB