• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I pass form data as a URI segment?

#1
[eluser]zulubanslee[/eluser]
Forms send by post by default, I would like to pass the data in the URI so I have a pretty link.

Is this a noob question? haha

#2
[eluser]Unknown[/eluser]
You can turn on query strings in the config.php file,

Code:
$config['enable_query_strings'] = TRUE;

Keep in mind though, when doing this your URI's will route differently, instead of symbollic links to your controllers and methods you'll run into the format

Code:
http://localhost/index.php/c=controller&m=method

Check out this article on enabling query strings.

Also, if you are using the Form helper, you can pass attributes to the form_open() method using a key value array. Setting a key/pair with method => get will do the trick.

Code:
form_open( $action, array( 'method' => 'GET' ) )

When using get, keep in mind that CI clears the $_GET array and stores the get variables internally, so when not using query strings the get variables can be recovered by using
Code:
$input->get( 'someVariable' );

#3
[eluser]zulubanslee[/eluser]
so i guess that means there's no way to do it without query strings. I wanted something like this:
example.com/search/blah


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


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