Welcome Guest, Not a member yet? Register   Sign In
Form in CI: POST and GET
#1

[eluser]developer10[/eluser]
Im rebuilding my site using CI and sooner or later i will have to rebuild basic search form

current live site (link in my signature) shows you how that looks. only 2 fields:
category and city.

if i use GET, i will end up having "?company=Something&city=Somecity"
and im not using querystrings in my CI development

i want my form after submitting to get me somewhere like this:
"mysite.com/index.php/show/company/city"

how do i accomplish that?

is using POST solution?

if i wasnt clear enough, just ask and i'll try to be more specific!

thanks in advance
#2

[eluser]Dam1an[/eluser]
There are several threads on mixing segments and query strings if you want.
If you want to stick with just segments and use POST, then the easiest method that comes to mind is to submit the form to an intermediate method, which then redirects you to the URL with the company and city in it and then the redirected methos would use them as parameters instead of $_POST variables
#3

[eluser]developer10[/eluser]
[quote author="Dam1an" date="1246936794"]There are several threads on mixing segments and query strings if you want.
If you want to stick with just segments and use POST, then the easiest method that comes to mind is to submit the form to an intermediate method, which then redirects you to the URL with the company and city in it and then the redirected methos would use them as parameters instead of $_POST variables[/quote]

wonder if that solution (mixing of segments with query strings) is officially regarded acceptable by the CI developers?
#4

[eluser]Colin Williams[/eluser]
Quote:wonder if that solution (mixing of segments with query strings) is officially regarded acceptable by the CI developers?

It isn't. They'll revoke your license. Tread carefully Smile The only case I would make for using query strings is if some API you are using requires them, or the sample code they provide makes use of them (Facebook App API is a good example.) There's nothing you can do with query strings that you can't do with segments.
#5

[eluser]garymardell[/eluser]
Query strings should only really be a compatibility option to link with existing code. The only time i have used query strings is with the api i wrote, to keep api's in a common format. However, its not exactly the worst thing in the world to use query strings, no dinosaur is going to pop out and eat you just because you used them.

( http://xkcd.com/292/ )
#6

[eluser]Phil Sturgeon[/eluser]
Query strings were only frowned upon for a while as they busted up your SEO. These days Google is clever enough to realise that index.php?page=home is different to index.php?page=news so the only real issues for you to worry about are Google Analytics page tracking (doesn't support query strings) and human URL readability.

The method Dam1an linked to is one I have been referencing for months. It has worked fine for me and every CI developer I have linked through to it.
#7

[eluser]developer10[/eluser]
[quote author="Colin Williams" date="1246945280"]
Quote:wonder if that solution (mixing of segments with query strings) is officially regarded acceptable by the CI developers?

It isn't. They'll revoke your license. Tread carefully Smile The only case I would make for using query strings is if some API you are using requires them, or the sample code they provide makes use of them (Facebook App API is a good example.) There's nothing you can do with query strings that you can't do with segments.[/quote]

well then, how to make my form after submitting to show something like this in the address bar:
/controller/function/Category/City/
instead of
/controller/function/?category=Category&city=City

What do i put as form's target? how do you guys deal with forms in order for it not to send
its values like the above example when using $_GET?
#8

[eluser]Phil Sturgeon[/eluser]
Huh? If you dont want to send variables over GET then use POST. It really doesn't matter that much.
#9

[eluser]Dam1an[/eluser]
And if you want to use POST (which you seem to have decided you do, or at least you don't want GET) and you really, really, really want the terms in the URL, do something like I suggested earlier
#10

[eluser]developer10[/eluser]
[quote author="Dam1an" date="1246978742"]And if you want to use POST (which you seem to have decided you do, or at least you don't want GET) and you really, really, really want the terms in the URL, do something like I suggested earlier[/quote]

Quote:Huh? If you dont want to send variables over GET then use POST. It really doesn’t matter that much.

as a matter of fact, i had the intention to use get because i would use those as parameters for my function/search result query

but, segments seem to be more suitable solution for me.

this issue can rest for now, until i find solution for more complex problem, regarding filtering results for showing (i 'll start new topic on this, very very soon) so help me on that if you know how

when that's resolved, i guess i'll know how to deal with this issue as well




Theme © iAndrew 2016 - Forum software by © MyBB