• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GET form causes 404

#1
[eluser]the real rlee[/eluser]
Hi guys, was wondering if someone could help me with this. I have a search form which returns a list of results which i paginate. For this to work I need to send a GET variables from CI, but i keep getting 404 erors.

Here's my form:

Code:
<?=form_open('locations/search', array('method'=>'get', 'onsubmit'=>"if (this.q.value == '') { alert('Please enter a store name, state or postcode'); return false; }"))?>
    <label for="q">postcode, suburb or state</label>
    &lt;input class="field" type="text" id="q" name="q" size="15" maxlength="255"  /&gt;
    &lt;input class="submit" type="submit" value="&gt;>" />
    &lt;?=form_close()?&gt;

My Controller:
Code:
function search ($page = 1, $per_page = 25) {
   die($this->input->get('q')));
}


At the moment then form is submiting to http://dev.mysite.com.au/locations/search?q=forest and i get Error 404...

Anyway any help appreciated Big Grin

#2
[eluser]marcoss[/eluser]
That's because CI destroys the GET array when you use segment-based urls, the easiest solutions is to use POST instead of GET, considering that your application allows that. Otherwise you can search the forum on how to support both GET and "nice" URL's.

#3
[eluser]the real rlee[/eluser]
ok figures, thanks marcoss. Looks like i'll have to append the value of the post value to the pagination url's ...

Code:
// pagination library config
$config['base_url'] = base_url().'gallery/q/'.$this->input->post('q', true).'/p/';


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.