Welcome Guest, Not a member yet? Register   Sign In
sending form parameters as URI Segments
#1

[eluser]Sanjabs[/eluser]
I have a form code (simplified for use):
<form name="search-institution" action="<?=base_url()?>institutions/index" method="get">
Search Text :
<input type="text" size="15" maxlength="100" name='keys'/>
<input type="submit" value="Search" name='Search2' />
</form>


When i submit the form: the uri looks like:
www.sampleweb.com/institutions/index?keys=value
but i prefer it to be like
www.sampleweb.com/institutions/index/value

I have disabled $config['enable_query_strings'] as FALSE;

But still query strings are not diabled???

Solutions please?
#2

[eluser]Dam1an[/eluser]
when you disable query strings in the config file, it opnly affects how CI builds all it's URLs internally
The get method is implemented in PHP itself, so CI doesn't control what the URL looks like when the form is posted (or should I say submitted?)
#3

[eluser]Phil Sturgeon[/eluser]
There is no clean way to do this as this goes against the HTTP standard way to submit forms.

Your two choices are a) use JavaScript to concatinate the URL based on form values or b) use POST to submit to the form action then use PHP to create a URL to redirect to.

Why not just use POST to send data straight to the form action? Get seems a funny way to handle it.
#4

[eluser]Dam1an[/eluser]
I just noticed it's a search form lol, which is why I'm guessing you want the segments in the URL
Then as Phil suggested, you could submit to an intermediate function, which would concat the search string with +, and then redirect to search/term1+term2+term3
You could then receive that as a single segment in the function that does the search, explode on + to get the individual terms, and do what you want




Theme © iAndrew 2016 - Forum software by © MyBB