Welcome Guest, Not a member yet? Register   Sign In
Not Passing encoded variable % to Controller
#1

I have to encode urls linking to my invoice pages.

on All invoice page:

Code:
<?php $pdfurl = urlencode(base64_encode($this->encrypt->encode($list->order_id)));
?>
                                                        
<a href="<?php echo base_url('pdf/'.$pdfurl);?>">Pdf2</a></td>
this encodes the url  
www.website.com/pdf/13
to www.website.com/pdf/Z1FSMmNkcG9NWHNrc2V3MzZvY2grY0pzQUVtSEZRYTFrMmU0RTMreWFNa3MzS29tdXhJRzJBUnQwNGJhR1lwcEZLdjUvTTlLbnJ0YmNSQ2Q2RTlyekE9PQ%3D%3D

My controller code is:
in controller when $pdfurl is called it carries Z1FSMmNkcG9NWHNrc2V3MzZvY2grY0pzQUVtSEZRYTFrMmU0RTMreWFNa3MzS29tdXhJRzJBUnQwNGJhR1lwcEZLdjUvTTlLbnJ0YmNSQ2Q2RTlyekE9PQ==
It drops %3D%3D and appends == at the end.

This doesnot decodes to the original variable value which is 13.

instead it decodes to : 
gQR2cdpoMXsksew36och+cJsAEmHFQa1k2e4E3+yaMks3KomuxIG2ARt04baGYppFKv5/M9KnrtbcRCd6E9rzA==

Pls help, i am doing this for first time.
Code:
function pdf($pdfurl){
    $this->load->library('pdf');
    $this->load->library('encrypt');

       $order_id = base64_decode(rawurldecode($pdfurl));
 

      $data = $this->common_data_admin();
        
        $data['order_id'] = $pdfurl;
        $data['order_details'] = $this->common_model->get_order_details($order_id);        

      $this->pdf->load_view('mypdf', $data);

My Config file has:

Code:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-@\=';

Route file:
Code:
$route['pdf/(:any)'] = 'Afterlogin_admin/pdf/$1';
Reply
#2

I don't think you need to call rawurldecode in your controller. I'm pretty sure it is already decoded for you. Try this:
PHP Code:
$order_id base64_decode($pdfurl); 
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply




Theme © iAndrew 2016 - Forum software by © MyBB