1
votes

I have a view which encrypts the current pid from database and when a 'save' button is clicked, it will redirect to the other controller.

My URL is encrypted. So, the 3rd segment in my URL is the pid, encrypted. So my URL will be:

 http://localhost/profile/edit_entry/3YnwZhh5hLiYEB2ICaPUgZs.6Ydz8C1mbyiGoJnTcw34Ejuy0sgeIasI3C2fVxoZca4SgZ9mjKsqmX.l8otGrw--

But When I decode it and try to echo it, it won't echo anything.

My controller:

$pid = $this->uri->segment(3);
    $pid = $this->encrypt->decode($pid);

    echo "$pid";

Nothing happens. Any idea?

1
as an alternative, try to get it in the method as an argument - Kevin
@Ghost What do you mean? Can you please elaborate? Thanks. - Taylor
instead of using segments, haven't you tried this pastebin.com/jvWzQbb9 - Kevin
Still not working ;( - Taylor
If you could explain the answer then others who might have the same problem could find this and figure it out too ... Please? ;) - Mr. Meeseeks

1 Answers

0
votes

This is the way i've tested and working:

First need to be loaded the Library 'encrypt' this can be loaded on autoload.php or just call the Library on your controller:

As i see, first of all you have created an encrypted id to no show the real id in the url, and you need to decrypt to get the id on post/edit/etc.

so, we will create a method Edit.

public function Edit($id){

            $this->load->library('encrypt');
            $pid = $this->uri->segment(3);
            $pid = $this->encrypt->decode($pid);

            var_dump($pid);
}