CodeIgniter Forums
Passing multiple variables on the URL - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Passing multiple variables on the URL (/thread-3776.html)



Passing multiple variables on the URL - El Forum - 10-21-2007

[eluser]omed habib[/eluser]
I have the following URL:

www.mysite.com/shoppingcart/

And I want to pass variables to it such as:

www.mysite.com/shoppingcart/?newproduct=12&promotion=yes&shipping=same&etc=etc&etc=etc&etc=etc

However, I don't want to pass them as subdirectories because if they are NOT present, the function will return an error.

How do I pass multiple variables in the URL without having to define each variable as inputs to the function and if they are not present at all the function will still work?

Thanks!!


Passing multiple variables on the URL - El Forum - 10-21-2007

[eluser]gunter[/eluser]
hm, you could parse the url with 3 or 4 lines code...


Passing multiple variables on the URL - El Forum - 10-21-2007

[eluser]Michael Wales[/eluser]
You could use URL segments and routing.

Route the /shoppingcart/ segment to a controller/method - then just parse out the other segments.

Honestly, this seems pretty sloppy and I would just use a session if possible.