c_pattle Posted November 24, 2011 Share Posted November 24, 2011 I have a function called "search" that handles a form submission. When I submit the form the URL is "products/search/". Is there a way to make the controller function output a different URL so instead it would be "products/search/searchCat/searchString" where searchCat and searchString are the two post values from the form? Below is my function function search() { $searchCat = $this->input->post('searchCat'); $searchString = $this->input->post('searchString'); $aData['query'] = $this->ProductModel->GetProductsBySearch($searchCat, $searchString); $aData['base_url'] = base_url(); $aData['breadcrumbs'] = create_breadcrumb(); $this->load->view('product_layout', $aData); } Thanks Quote Link to comment https://forums.phpfreaks.com/topic/251714-codeigniter-write-url-from-controller/ Share on other sites More sharing options...
trq Posted November 24, 2011 Share Posted November 24, 2011 Your question is pretty unclear. Do you wan't this controller to redirect to products/search/searchCat/searchString ? or you want the form to post to products/search/searchCat/searchString ? Quote Link to comment https://forums.phpfreaks.com/topic/251714-codeigniter-write-url-from-controller/#findComment-1290907 Share on other sites More sharing options...
c_pattle Posted November 24, 2011 Author Share Posted November 24, 2011 I want the controller to redirect to products/search/searchCat/searchString but it will replace the last two parts of the URL with the post values Quote Link to comment https://forums.phpfreaks.com/topic/251714-codeigniter-write-url-from-controller/#findComment-1290914 Share on other sites More sharing options...
samitrimal Posted November 25, 2011 Share Posted November 25, 2011 Try Uri routing. http://codeigniter.com/user_guide/general/routing.html Quote Link to comment https://forums.phpfreaks.com/topic/251714-codeigniter-write-url-from-controller/#findComment-1291136 Share on other sites More sharing options...
jotorres1 Posted November 30, 2011 Share Posted November 30, 2011 Just add parameters to your function function search($searchCat, $searchString){ etc.. } Quote Link to comment https://forums.phpfreaks.com/topic/251714-codeigniter-write-url-from-controller/#findComment-1292674 Share on other sites More sharing options...
jotorres1 Posted December 7, 2011 Share Posted December 7, 2011 You should read this post I have just published. http://www.jotorres.com/en/2011/12/remapping-function-calls-in-codeigniter/ It should help out with uri-rerouting, and have nicer looking urls. Quote Link to comment https://forums.phpfreaks.com/topic/251714-codeigniter-write-url-from-controller/#findComment-1295496 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.