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?

3

4 Answers 4

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

Sign up to request clarification or add additional context in comments.

2 Comments

@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.
With this approach you can put the application in risk, because you're breaking routing rules.
5

Use this:

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

EDIT:

In PHP >=7.0, you can do this:

$code = $_REQUEST['code'] ?? NULL;

Comments

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']; 

1 Comment

@CollinsAbitekaniza, but it is codeigniter method, and it doesn't clean XSS
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.