简体   繁体   English

确认Codeigniter食品杂货店中的表单提交错误

[英]Confirm form submission error in codeigniter grocery crud

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 我正在尝试登录到admi面板并使用以下代码在admin中进行编辑

 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 请提供此问题的解决方案

It happens because the action that took you to that page was a POST request. 发生这种情况是因为将您带到该页面的操作是POST请求。 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 我通常将用户重定向到由GET请求加载的页面,它甚至可以是同一页面,请参见以下答案: https : //stackoverflow.com/a/3968038/357403
Or, you could modify the history: https://developer.mozilla.org/en-US/docs/Web/API/History_API 或者,您可以修改历史记录: 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 另外,请参阅PRG模式: https : //en.wikipedia.org/wiki/Post/Redirect/Get

Try this code format: 尝试以下代码格式:

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

or 要么

redirect('home', 'refresh');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM