2013-07-11 81 views
-2

如何将帖子变量传递给网址?我可以从网址读取它,但我不能把它... 我有什么至今:$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); 


    }` 

我怎样才能发布变量的find()函数与网址段?

回答

0

你需要有找到接受参数使用默认的

function find($i=0) { 
    //$i is whatever is in the URL or defaults to 0 
+0

是的但我后发现找到函数r edirects到查找查看器和网址保持mysite /找到而不是mysite/find /项目 –

+0

如果你发布到'yoursite/controller/find',你不会得到那个变量,你需要发布到'yourside/controller/find/id'或发送POST数据,而不是从params收集,你可以使用CI的输入类。即$ i ='$ this-> input-> post('post_var_name');' – bizzehdee

+0

所以我需要改变这个 <?php echo form_open('shop/find','find'); ?> <?php echo form_close(); ?> 用$ this-> input-> post代替提交? –

0

在你看来:

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

控制器:

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

你需要下载的形式帮助过