6

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?

vzwick
  • 11,008
  • 5
  • 43
  • 63
KraigBalla
  • 363
  • 2
  • 6
  • 14

4 Answers4

8

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

PhearOfRayne
  • 4,990
  • 3
  • 31
  • 44
  • @KraigBalla Take a look at my updated answer, I always seem to have better luck when I use `REQUEST_URI` instead of `AUTO`, also I added a quick suggestion for how I would go about this using URI segments. – PhearOfRayne Dec 26 '12 at 22:49
  • With this approach you can put the application in risk, because you're breaking routing rules. – Silvio Delgado Sep 21 '17 at 22:26
5

Use this:

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

EDIT:

In PHP >=7.0, you can do this:

$code = $_REQUEST['code'] ?? NULL;
Silvio Delgado
  • 6,798
  • 3
  • 18
  • 22
4

I did this and it worked without having to change the config file:

//put some vars back into $_GET.
parse_str(substr(strrchr($_SERVER['REQUEST_URI'], "?"), 1), $_GET);

// grab values as you would from an ordinary $_GET superglobal array associative index.
$code = $_GET['code']; 
KraigBalla
  • 363
  • 2
  • 6
  • 14
0

can you please try

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

instead of

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

without any config or else edit please

itsme
  • 48,972
  • 96
  • 224
  • 345