Faryal Khan
Faryal Khan

Reputation: 869

Change url in php after reloading a page

My home page url looks like this

http://localhost/mediabox/home/box/12

I have a link of language on home page when a user clicks on that link i am sending that language id as query string , the page reloads and the url converts to

http://localhost/mediabox/home/box/?bid=12&ln=2

I want to reload the page with the new language but don't want to change my url i-e I want my URL to be

http://localhost/mediabox/home/box/12

after the page loads

How it is possible please me some gud ideas Thanks

Upvotes: 1

Views: 1711

Answers (1)

W Kristianto
W Kristianto

Reputation: 9303

VIEW

<a href=<?php echo site_url('home?language=indonesian');?>>Indonesian language</a>

CONTROLLER

class Home extends CI_Controller {

    public function index()
    {
        $language = $this->input->get('language');
        if($language){

            // Put your code here

            // Now u can set session
            $this->session->set_userdata('language', $language);
            redirect('home');
        }

        if($this->session->userdata('language'))
        {
            var_dump($this->session->userdata('language'));
        }
        echo 'Hello World!';
    }

}

Upvotes: 1

Related Questions