Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] $this->input->get: How to use it ?
#11

[eluser]demogar[/eluser]
Hey sikko.

I would do something different like I said in the other post I linked.

Code:
// Controller:

function form() {
  # load libraries (form_validation and form)
  if ( ! form_validation->run()) {
    $this->load->view('form');
  } else {
    $search = base64_encode($this->input->post("search"));
    redirect("search/" . $search);
  }
}

function search($string) {
  $string = base64_decode($string);
  # Work with the string. Use Zend Lucene for example.
}

Why base64_encode and not uri_encode (I guess you mean urlencode)? Because for me is better if I want to preserve the string in the same way it was typed.

Codemaster Snake, you can use $this->input->get(); for all the get variables and thats all. Use the CI routing defaults and you can use an URL like:

Quote:index.php/search/ instead of /index.php?var1=something&var2=bla&var3=foo

Inside your search controller just add:
Code:
$var1 = $this->input->get('var1');
$var2 = $this->input->get('var2');

Happy coding :]
#12

[eluser]sikko[/eluser]
Yeah nice solution demogar. It may also avoid to have the message when the page is refreshed thank to redirect.
i will try it and give you some feedback
thx see ya
#13

[eluser]sikko[/eluser]
Humm.. I have a problem...

I created my search controller (named search.php) but:

I can't name my function search because the constructor is already named "search".
I guess I shouldn't create this controller or change the name of the "search" function but:
I can see you use
Code:
redirect("search/" . $search);
The first segment of the url stands for the controller that means that there must be a controller named "Search" BUT! As I noticed before, I cannot create this controller...

So as you can read... I'm totally confused... Confused

Where should I place my two functions ? Should I create a new controller for the search engine ?
#14

[eluser]demogar[/eluser]
LOL..

Name your controller search, in your index you have the form then you redirect to do_search which is a function inside your search controller then...

I think you can figure it out by yourself... good luck
#15

[eluser]sikko[/eluser]
ok that works fine thanks!
but now I think i will restructure my application using uri routing.

thank you bye !




Theme © iAndrew 2016 - Forum software by © MyBB