I am trying to pass values from my view to controllers in codeigniter. When i pass the values to my controller, the values show in my url. How do i pass the values without showing it in the url ?

View

<p class="info"><a href="<?php echo base_url("customer/details/" . $customer->id . "/" . $customer->card . "/data"); ?>" 
class="css">Submit</a></p>

Controller

public function option_standard()

{
    $data['id'] = $this->uri->segment(3);
    $data['amt'] = $this->uri->segment(4);
    $data['page_content'] = 'customer/details';
    $this->load->view(layout, $data);
}

3 Answers

0
nipun rmt On

Just pass the customer_id via URL and retrieve the data you wants to display in the next page via using the customer_id. Also you can use a hidden HTML field to pass data .

0
Javier Larroulet On

Anything you pass without using POST will be visible in the query string. That's how it works. If you can't or won't switch to POST your best bet is to reduce the amount of data you pass via query string to the absolute minimum (maybe just the customer ID) and have the controller fetch out the rest. Remember, though, you still need to validate the input.

Hidden fields (which work only on forms) will also be visible in the query string if the form passes data using GET instead of POST you there's no benefit in using those in your case.

Another alternative would be to pass data back to the controller using Ajax, but the data will still be visible in the browser's console so in terms of security (or obscurity) there would be no real gain.

0
DFriend On

Instead of passing $customer->id in the URL, store it as session data that is retrieved at the linked URL.