doushizhou4477 2015-08-05 11:12
浏览 5
已采纳

无法清除codeigniter中的变量

this is my controller:-

public function home() {
    if($this->session->userdata('id')) {
        $this->header();
        $this->load->model('admincon');
        $e = $this->admincon->select();
        $data['e'] = $e;
        $this->load->view('admin/home',$data);
    } else {
        $this->index();
    }
}

in the view page of function home() there is a form which submitted through function subques() the function is here:-

public function subques() {
    if($this->session->userdata('id')) {
        $tp=$this->input->post('box1',TRUE);
        $s=$this->input->post('box',TRUE);
        $t=$this->input->post('t',TRUE);
        $a=$this->input->post('a',TRUE);
        $b=$this->input->post('b',TRUE);
        $c=$this->input->post('c',TRUE);
        $d=$this->input->post('d',TRUE);
        $n=$this->input->post('n',TRUE);    
        $this->load->model('admincon');
        $this->admincon->subque($s,$t,$a,$b,$c,$d,$n,$tp);

        $this->home();
    } else {
        $this->index();
    }
}

but after submitting the values to the database when user redirected to the page if they click on refresh button the previous data store into the database another time. how to solve this problem.

i mean how to clear the variables after use them.

  • 写回答

2条回答 默认 最新

  • dongping1012 2015-08-05 11:28
    关注

    User redirect() instead of $this->home()

     public function subques()
    {
       if($this->session->userdata('id'))
       {
           $tp=$this->input->post('box1',TRUE);
           $s=$this->input->post('box',TRUE);
           $t=$this->input->post('t',TRUE);
           $a=$this->input->post('a',TRUE);
           $b=$this->input->post('b',TRUE);
           $c=$this->input->post('c',TRUE);
           $d=$this->input->post('d',TRUE);
           $n=$this->input->post('n',TRUE);    
           $this->load->model('admincon');
           $this->admincon->subque($s,$t,$a,$b,$c,$d,$n,$tp);
    
           redirect('controller_name/home');
      }
       else
       {
           redirect('controller_name/index');
       }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作