-2

如何将 post 变量传递给分段 url?我可以从 url 读取它,但我无法设置它......到目前为止我所拥有的:$route['shop/find/(:any)']= "shop/find/$1";在路线上,我的 find.php 在视图上,以及我的功能`

function find()
    {
            $this->load->model('shopFront/find');
            $this->load->model('currency');
            $this->load->model('shopFront/calculate');
            $this->load->model('shop/proccess');
            $data = $this->commondatashop->general();
            $inputSlug = $this->input->post('findSlug');
            $data['tofind'] = $inputSlug;
            $data['cartInfo'] = $this->shopcart;
            $data['Currency'] = $this->currency;
            $data['Calculate'] = $this->calculate;
            $data['Proccess'] = $this->proccess;
            $data['title'] = "1.4.U Shop | Find";
            $finder = $this->find;
            $data['finderservice'] = $finder;
            $data['user_id'] = $this->session->userdata('user_id');
            $data['user_name'] = $this->session->userdata('user_name');
            $this->load->view('shop/top/topNew',$data);
            $this->load->view('shop/content/find',$data);

            //footer
            $curravailable = $this->calculate->getCurrencies();
            if ( $curravailable !== false )
            {
                $data['currencies'] = $curravailable;
            }
            else
            {
                $data['currencies'] = 'none';
            }
            $this->load->view('shop/footer',$data);


    }`

如何将变量发布到带有 url 段的 find() 函数?

4

2 回答 2

0

您需要 find 接受具有默认值的参数

function find($i=0) {
  //$i is whatever is in the URL or defaults to 0
于 2013-07-11T22:45:02.840 回答
0

在您看来:

echo form_open('/shop/find');
echo form_input('findSlug','');
echo form_submit('submit', 'Submit');
echo form_close();

控制器:

$data[slug] = $this->input->post('findSlug');

您也需要加载表单助手

于 2013-07-12T03:28:32.220 回答