Php – CodeIgniter – Routing urls with GET Variables


I checked the similar questions out there, but those doesnt seem to help.

I have an email verification like, that is to be routed in CodeIgniter to the right function with data passed to the function for further processing.

Sample URL :

Current Route :

$route['verify/(:any)'] = 'formcontroller/verification/$1';

Function :

public function verification($slug)
        parse_str(parse_url($slug, PHP_URL_QUERY), $fileds);

The problem is, I get a 404 when I try the url listed above. I get Message: Undefined variable: fields when I try something like

Can someone point me in the right direction?

ADD : If there is no ? in the url, it works. But for the standard of a get query url should be, I would like like to know how to solve this

Best Solution

Route doesn't receive query string as i understand. So, you should get variable from GET array. For this, 1st test that in config.php set

$config['allow_get_array'] = TRUE;

then in controller:

public function verification($slug)
    $fields['id'] = $this->input->get('id');
    $fields['hash'] = $this->input->get('hash');
Related Question