0

When i click on back button, i got the confirm form submission error .How to prevent this issue?Please provide solution for this. I am trying to login to the admi panel and edit in admin in this following code

 Admin controller:
        public function index()
        {

            $data = $this->data;
            $this->load->view('admin/login.php',$data);
        }
        public function login()
        {
            $data = $this->data;
            $username=$this->input->post("username");
            $password=$this->input->post("password");

            if($username=='admin'&&$password=='admin123')
            {

                $this->load->view('admin/home.php',$data);

            }
            else
            {
                $data['error']="Invalid Username or Password";
                $this->load->view('admin/login.php',$data);
            }
        }

        /* Function For Displaying the home page*/
        public function home()
        {

            $data = $this->data;
            $this->load->view('admin/index.php',$data);
        }
        /* Common Function for calling the View*/
        public function _admin_output($output = null)
        {
            $output->base=$this->config->item('base_url');
            $output->site=$this->config->item('site_url');
            $output->css=$this->config->item('css');
            $output->js=$this->config->item('js');
            $this->load->view('admin/home_page.php',$output,'refresh');

        }

            public function loadSlidingimg()
        {
            $crud = new grocery_CRUD();
            $crud->set_table('tbl_slideimg');
            $crud->columns('imgname','active');
            $crud->set_subject('Frontpage Sliding Images');
            $crud->display_as('imgname','Image name');
            $crud->set_field_upload('imgname','uploads');   
            $crud->display_as('active','Active Flag');
            $crud->callback_after_update(array($this,'rename_slideimg_db'));
            $crud->callback_after_insert(array($this,'rename_slideimg_db'));

            $output = $crud->render();
            $this->_admin_output($output);
        }
        }

Please provide solution for this issue

user
  • 213
  • 5
  • 18

2 Answers2

0

It happens because the action that took you to that page was a POST request. The browser wants to save you from unintentional double-ordering/paying/whatever when you go "back", when loading that page would need to do the form posted again.

How to work that around? I usually redirect the user to a page which was loaded by a GET request, it can be even the same page, see this answer: https://stackoverflow.com/a/3968038/357403
Or, you could modify the history: https://developer.mozilla.org/en-US/docs/Web/API/History_API

Also, please see the PRG pattern: https://en.wikipedia.org/wiki/Post/Redirect/Get

Community
  • 1
  • 1
Koshinae
  • 2,240
  • 2
  • 30
  • 40
  • how to solve the issue in my above code. Please provide solution for this – user Oct 19 '15 at 07:49
  • What is the workflow? In which function do you enter? Where are you when you click "back", and which url it should be where the "back" goes back? (Please answer all 3) – Koshinae Oct 19 '15 at 07:53
  • $this->load->view('admin/home_page.php',$output,'refresh'); here is my problem – user Oct 19 '15 at 08:00
0

Try this code format:

$this->load->view('admin/home.php', 'refresh', $data);

or

redirect('home', 'refresh');
smottt
  • 3,272
  • 11
  • 37
  • 44
B.Nadesh kumar
  • 216
  • 1
  • 10
  • the above code is not working . i want to redirect in to the home_page not to the home page. – user Oct 20 '15 at 04:30