Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
796 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 Answer

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

}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...