my work
my work

Reputation: 41

how to mask the id in url (codeigniter)

This is my routes i have change the url

$route['default_controller'] = 'Customer';
$route['register'] = 'staff/register'; 
$route['admin'] = 'user/display_admin_dashboard';
$route['customer/display_medicine_prescription'] = 'customer/display_medicine_prescription/(:any)';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route[LOGIN_PAGE] = 'examples/login';

customer/display_medicine_notification/14

this is my url how hide the id (14)

Upvotes: 0

Views: 1997

Answers (2)

demenvil
demenvil

Reputation: 1139

U can use slug-name ex :

http://localhost/display_medicine_prescription/(slug-name)

route.php

$route['display_medicine_prescription/(:any)'] = 'customer/display_medicine_prescription';

And your model :

 public function display_medicine_prescription($slug = FALSE){
        if ($slug === FALSE){
                $query = $this->db->get('medecine');
                return $query->result_array();
        }

        $query = $this->db->get_where('medecine', array('slug' => $slug));
        return $query->row_array();
    }

Upvotes: 1

Andrew
Andrew

Reputation: 846

Just try it i think its work

$route["display_medicine_prescription/([0-9]+)/(.*)"] ="customer/display_medicine_prescription";

Upvotes: 0

Related Questions