phpcodeigniteruricodeigniter-3request-uri

get value parameter from url codeigniter


hello I want to ask getting value parameter from url to my controller

I set redirecting url from javascript like this,

window.location.href = '<?php echo base_url().'index.php/form_tambahasset'?>' + '?lang=' + lg + '&lat=' +lt;

and I need to bring parameter lang and lat to my next page,

http://localhost/BTS_CI/index.php/form_tambahasset

if I set redirect url to be like this,

http://localhost/BTS_CI/index.php/form_tambahasset/lang/107.39410400390625/lat/-6.671700384923497

it must be 404 page not found.

how can I get value parameter lang and lat ? my position of my $config['uri_protocol'] at REQUEST_URI now but I was try change into PATH_INFO it doesn't work to me.

I was try $this->uri->segment(3, 0); and parse_str($_GET['lat'], $_GET); still doesn't work to get my param.

my page of

http://localhost/BTS_CI/index.php/form_tambahasset?lang=107.39410400390625&lat=-6.671700384923497

is doing fine, but I need to get my param value

any solution for my problem? please help me. thank you


Solution

  • Just need to look at the documentation.

    $this->input->get('lang', TRUE); // TRUE is for XSS filtering
    $this->input->get('lat', TRUE); // TRUE is for XSS filtering
    

    Codeigniter Input Class - Using POST, GET, COOKIE, or SERVER Data