Welcome Guest, Not a member yet? Register   Sign In
GET parameter
#1

[eluser]flokky[/eluser]
Hi,
I've created a page which generates a bunch of links which invokes another controller in my application (e.g. frontpage generates a link like http://www.example.com/page.php?id=23 where page is my other controller)

I need to fetch the id from the $_GET parameter in order to look up the needed values from the db. As I have understood from the input user guide, CI does not allow any parameters to be submitted from this $_GET

As only $_POST variables are allowed, I don't know how to persue this. I've also tried http://www.example.com/page.php/23, but that just resulted in a 404.

Any help given would be great!
#2

[eluser]ontguy[/eluser]
Your URL could look something like this: http://www.example.com/page/view/23

This would look for a controller named "page" with, a function named "view" with 23 as the parameter.
http://ellislab.com/codeigniter/user-gui...passinguri
#3

[eluser]Matthew Lanham[/eluser]
And to get in the example above from ontguy to get 23 to use for DB etc you should look up:

http://ellislab.com/codeigniter/user-gui...s/uri.html

Specifically in his example

$this->uri->segment(3) would give you 23
#4

[eluser]flokky[/eluser]
Both: thank you for those great replies! It actually solved my problem.

I already tried this before posting into this forum, but I invoked it directly from the index method. That didn't worked unless you give the method name explicitly.

I tried fetching the segment in the Page controller in the index-method. http://www.example.com/page.php/23 would result in a 404 which is strange, since I thought the index method is always invoked, even inexplicitly. When changing to http://www.example.com/page.php/index/23 this is working.
#5

[eluser]ontguy[/eluser]
np.

This post may help with passing parameters to the index function without index in the url.
http://ellislab.com/forums/viewthread/72367/
#6

[eluser]flokky[/eluser]
Ontguy: thanks again!

Just as a follow-up message: there has been a change in the way routes.php is designed: in the thread you've given they are still using the old way.

Old way: $route['browse.*'] = 'browse/index';

New way: $route['browse/:num'] = 'browse/index';




Theme © iAndrew 2016 - Forum software by © MyBB