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

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

This is the link that the user will click on the e-mail.

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?

+4
source share
4 answers

I did this and it worked without changing the configuration 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']; . //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']; ordinary $ _GET superglobal array associative index. //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']; 
+5
source

In your config.php , change the following:

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

To:

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

Instead of messing around with Query Strings, you can change your URI for the use of such segments as http://www.site.com/confirm/code/f8c53b1578f7c05471d087f18b343af0c3a638 . To access the code segment, you have to use $this->uri->segment(3); . Personally, I prefer this way of using Query Strings. See. The URI-class

+8
source

Use this:

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

EDIT:

In PHP> = 7.0 you can do this:

 $code = $_REQUEST['code'] ?? NULL; 
+2
source

can you try

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

instead

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

without any configuration or change please

0
source

All Articles