JEagle
JEagle

Reputation: 147

Getting $_GET to work with Codeigniter

I've seen several examples but i can't seem to get it working.

Config.php:

$config['uri_protocol'] = "PATH_INFO";  
$config['enable_query_strings'] = TRUE;

Library:

class MY_Input extends CI_Input  
{  
    function _sanitize_globals()  
    {  
        $this->allow_get_array = TRUE;  
        parent::_sanitize_globals();  
    }  
}  

Controller:

$this->load->library('MY_Input');  
..................  

$sid=$this->input->get('sid',TRUE);  
$name=$this->input->get('name',TRUE);  
$campid=$this->input->get('campid',TRUE);  
$rate=$this->input->get('rate',TRUE);  
$status=$this->input->get('status',TRUE);  

Here's the url:

www.mysite.com/memb/index/postback.php?campid=23552342&name=mcamp&rate=15&sid=42&status=1&ip=198152999000

What happens is that it just goes to my home page and doesn't update the db and it doesn't go to the test view page i added in the controller just to see if would load a view.

Edit: Now it seems that if i try to load other views i always end in the home view...

Upvotes: 0

Views: 442

Answers (2)

Tuong Le
Tuong Le

Reputation: 19220

I think what you need to do is open the application/config/config.php file, then:

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

Upvotes: 0

dockeryZ
dockeryZ

Reputation: 3981

put this in your controller

parse_str($_SERVER['QUERY_STRING'],$_GET);

Then you can use your $_GET variables like normal... ie. echo $_GET['var']

Upvotes: 1

Related Questions