Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将post变量传递到url_Php_Codeigniter - Fatal编程技术网

Php 将post变量传递到url

Php 将post变量传递到url,php,codeigniter,Php,Codeigniter,如何将post变量传递给段url?我可以从url读取它,但我不能设置它。。。 到目前为止我拥有的:$route['shop/find/(:any)]=“shop/find/$1”视图上的my find.php和我的函数` function find() { $this->load->model('shopFront/find'); $this->load->model('currency');

如何将post变量传递给段url?我可以从url读取它,但我不能设置它。。。 到目前为止我拥有的:
$route['shop/find/(:any)]=“shop/find/$1”视图上的my 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()函数中?

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

function find($i=0) {
  //$i is whatever is in the URL or defaults to 0
在你看来:

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

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

您也需要加载表单帮助程序

是的,但是我发布以查找,并且查找函数重定向到查找查看器,url保持为mysite/find而不是mysite/find/item如果发布到
yoursite/controller/find
,您将无法获得该变量,您需要将post发送到
yourside/controller/find/id
,或者将post数据与post一起发送,而不是从params收集,您将使用CI的输入类。i、 e.$i=
this->input->post('post_var_name')所以我需要用$this->input->post来更改它,而不是提交