Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeIgniter $this->input->get() not working

I'm not sure why this is not working. I have allow_get_array = TRUE in the config file. Here's what I am trying to do..

This is the link that the user will click from their email

http://www.site.com/confirm?code=f8c53b1578f7c05471d087f18b343af0c3a638

confirm.php Controller:

$code = $this->input->get('code');

also tried

$code = $this->input->get('code', TRUE);

Any ideas?

like image 427
KraigBalla Avatar asked Dec 26 '12 22:12

KraigBalla


2 Answers

In your config.php change the following:

$config['uri_protocol'] = 'AUTO';
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
$config['enable_query_strings'] = FALSE;

To:

$config['uri_protocol'] = 'REQUEST_URI';
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-?';
$config['enable_query_strings'] = TRUE;

Instead of messing with Query Strings you could change your URI to use segments like http://www.site.com/confirm/code/f8c53b1578f7c05471d087f18b343af0c3a638. To access the code segment you would use $this->uri->segment(3);. Personally I prefer this way as to using Query Strings. See URI Class

like image 106
PhearOfRayne Avatar answered Oct 05 '22 03:10

PhearOfRayne


Use this:

$code = isset($_REQUEST['code']) ? $_REQUEST['code'] : NULL;

EDIT:

In PHP >=7.0, you can do this:

$code = $_REQUEST['code'] ?? NULL;
like image 37
Silvio Delgado Avatar answered Oct 05 '22 03:10

Silvio Delgado