method GET in search result - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: method GET in search result (/showthread.php?tid=29783) |
method GET in search result - El Forum - 04-21-2010 [eluser]davidino86[/eluser] Hi everybody, i'm coding a search function that at the form submit, send GET data like this: Code: mysite.com/search/result?from=annunci&search=depilazione there is a function or configuration or something in CI that makes this without a rewrite role? method GET in search result - El Forum - 04-21-2010 [eluser]mddd[/eluser] I have used two ways to do that. 1. Use Javascript to handle the form. Before submitting the form, you change the form's "action" attribute, using the form's values. Something like: Code: (html) 2. Use a forwarding mechanism. You send the form (with POST). In CodeIgniter, you rewrite the address and forward to a new page. Something like: Code: $url = site_url('search','result',$this->input->post('from'),$this->input->post('search')); method GET in search result - El Forum - 04-21-2010 [eluser]davidino86[/eluser] i think the second one is the best for my idea, beacause if i put in a robot.txt some urls like search/result/var1/var2 the robots can find a page and i think this is something good for google. i don't know if i'm explain. method GET in search result - El Forum - 04-21-2010 [eluser]davidino86[/eluser] _YESSS! it works fine with the your second solution but i change the code: Code: function index() 'cause header didn't work and i change the url var in another way.is it correct? method GET in search result - El Forum - 04-21-2010 [eluser]mddd[/eluser] Oh, I'm sorry, I was too quick with the header. It should be : header('Location: ' . $url); But redirect() is fine; that basically does the same thing and it even has some more possibilities. Seems fine to me. I am glad it worked for you! |