-1

I'm having a problem regarding passing parameter from url. The function I use sometimes give the correct result and sometimes not.

here is my controller functions:

    public function link_gen(){
    $text = "i have lost my password please help me";

    $encrypted_text = $this->encrypt->encode($text);
    $encrypted_url = urlencode($encrypted_text);
    echo $encrypted_url. br();

    echo br(). $this->retrive(urldecode($encrypted_url));

    echo anchor('encryption/ret_back?username='.$encrypted_url, 'click me');

// echo anchor('encryption/ret_back/'.$encrypted_url, 'click me'); }

public function ret_back(){

// echo br(). $this->retrive(urldecode($str));

            $user = $this->input->get('username');
    echo br(). $this->retrive(urldecode($user));

    echo $user. br();
    echo "hellooooo". br();
}

For the sake of testing I'm encrypting a text then encode it in URL using urlencode(), then I pass this string to another function using URL, and then decode in the string in URL using urldecode() and then decode the text. But when I run this, sometimes the decoded text appears and sometimes it does not.

Can anybody tell me the reason and solution for this?

I want to use this in a 'forgot password' module.

Salman Asif
  • 11
  • 1
  • 1
  • 3
  • you should document your question better, did you debugged what's happening? how do you retrieve data from url ? – itsme Apr 03 '13 at 20:06

1 Answers1

0

It depends on how you create your links and how do you retrieve the data from url.

Anyway these are simple examples to get url data:

  1. get from $_GET[] (http://site.com/?q=hello+world) in this case you get the param q with echo $this->input->get('q',true);

  2. get data from uri segments (http://site.com/id/230) in this case you get id value via echo $this->uri->segment(2);

Then, if data in url exists it is not possible that the system didn't get that, so be sure data is in your url when opening url.

itsme
  • 48,972
  • 96
  • 224
  • 345
  • thak you for your response i really appreciate, plese check my code i have edit my post... please keep this post as it is too... – Salman Asif Apr 04 '13 at 03:46
  • @SalmanAsif you forgot the needed part ** echo br(). $this->retrive(urldecode($str)); ** what that method does? maybe your problem is the returned value from that method!? – itsme Apr 04 '13 at 07:20
  • the CI encrypt library uses $this->encrypt->decode( var ) – b_dubb Jul 31 '15 at 17:30