douyun1860 2016-02-19 21:09
浏览 50

如何使用codeigniter将数据数组从视图传递到控制器

I had a problem when trying to retrieve data from the array ( from view to controller ) , I've tried to use the session in view . but could not as well .

contrroller:

public function returnurl()
    {
        $dataview =  $this->load->view('user/return_url');
        // $this->load->view($this->template,$dataview);

        $status = $dataview['PAYMENT_STATUS'];

        if ($status == 'S'){
            redirect(site_url('registration/previewData'));
        } else {
            redirect(site_url());
        }
    }

view:

<?php
 var_dump($_POST);exit;

 foreach ($_POST as $name => $value) {
    echo $name . ' : ' . $value . '<br />';

}

$this->session->set_userdata($_POST);
  ?> 
</body>
</html>

Output array from view:

array(2) { ["PAYMENT_STATUS"]=> string(1) "S" ["MERCHANTID"]=> string(9) "testingid"}

I would like if payment_status = 'S' . he will redirect another page (as I have defined in the controller).

Has anyone already encountered this problem ? Please help , thanks before .

  • 写回答

1条回答 默认 最新

  • dougao9864 2016-02-19 21:16
    关注

    That's not how MVC works. Please read more about what each of them stands for. The data is passed from a controller to the view for presentation.

    In order to pass some data to a controller, you should make another server request (like submitting a form or making an AJAX call) and then read the data.

    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)