当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Pass post variable to url

问题描述:

How can i pass the post variable to segment url? i can read it from url but i can't set it...

What i have so far : $route['shop/find/(:any)']= "shop/find/$1"; on routes,my find.php on views, and my function `

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);

}`

How can i post the variable to the find()function with url segment?

网友答案:

you need to have find accept an argument with a default

function find($i=0) {
  //$i is whatever is in the URL or defaults to 0
网友答案:

In your view:

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

Controller:

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

You need to load form helper too

分享给朋友:
您可能感兴趣的文章:
随机阅读: