Routing and URI parsing in Codeigniter
-
26-09-2019 - |
Question
I have a route defined in CI,
$route['user/activate-account/:any'] = "user/activate_account";
People access the route in this url pattern,
http://mydomain.com/user/activate-account/user_id/12345/token/abcdefghijk
Inside the activate_account
function, I tried to use the following codes to retrieve the required data,
$user_id=$this->input->get('user_id');
$token=$this->input->get('token');
But they return FALSE, does this mean that for this kind of url pattern, I am supposed to use the functions provided by the URI class (http://codeigniter.com/user_guide/libraries/uri.html) to retrieve the variables?
Solution
Since your url is re-routed, you would need to use:
$usre_id = $this->uri->rsegment(n);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow