Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
799 views
in Technique[技术] by (71.8m points)

codeigniter - 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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!';
    }

}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...