oussama kamal
oussama kamal

Reputation: 1037

Codeigniter, sending data with url

I have a codeigniter Controller that has an index page that accepts 4 parameters like the followng :

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Upload extends CI_Controller {

    public function index($file_name = NULL, $PID = NULL, $Email = NULL, $password = NULL){
        if($file_name === NULL){
           $this->output    
                ->set_content_type('application/json')
                ->set_output(json_encode(array("status"=> "failure", "message" => "The file name is missing")));          
        }else if($PID === NULL){
            $this->output    
                ->set_content_type('application/json')
                ->set_output(json_encode(array("status"=> "failure", "message" => "The PID is missing")));
        }else if($Email === NULL){
            $this->output    
                ->set_content_type('application/json')
                ->set_output(json_encode(array("status"=> "failure", "message" => "The email is missing")));
        }else if($password === NULL){
            $this->output    
                ->set_content_type('application/json')
                ->set_output(json_encode(array("status"=> "failure", "message" => "The password is missing")));
}else{
$this->output    
                ->set_content_type('application/json')
                ->set_output(json_encode(array("status"=> "success", "message" => "Upload Done")));
}
}
}

the route.php file looks like :

$route['Upload/(:any)'] = "Upload/index/$1";
$route['Upload/(:any)/(:any)'] = "Upload/index/$1/$2";
$route['Upload/(:any)/(:any)/(:any)'] = "Upload/index/$1/$2/$3";
$route['Upload/(:any)/(:any)/(:any)/(:any)'] = "Upload/index/$1/$2/$3/$4";

I want to call the Controller index method an provide all data like the following:

www.mysite.com/Upload/myfile.csv/367/[email protected]/mypass;23!ù/o*

if I run it like that I get :

An Error Was Encountered

The URI you submitted has disallowed characters.

What is the best way to encrypt each data and send them all within the URL like above?

I tried base64 but same issue, any ideas please?

Thanks

Upvotes: 0

Views: 108

Answers (1)

AleMelo
AleMelo

Reputation: 128

Hey Man just change your config.php put this on on your permitted chars

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

you can variate depending on what you need

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

Upvotes: 1

Related Questions