Question

I have a link to a modal

echo anchor('welcome/test/?$userid', 'Full View', 'class="ajax"');

and when my modal opens i retrieve it

$id= $_GET;

reason being is that when you click the "full View" link the modal opens and display different content fetched from my database depending on the id. Codeigniter will not let me pass $userid since $ is a forbidden character. Is there anyway to get round this obstacle without enabling $ in

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';

adding $ in the config would open up my application to sql injections right?

So basicly what I wish to achieve is to pass the ID from my view my modal window (that allso is a view)

Était-ce utile?

La solution

Add the route to the routes.php config file

    $route['welcome/test/(:num)'] = "{your_controller}/{your_function}/$1";

And this will allow you to have the link just as

welcome/test/$user_id 

and it will call your function with $user_id as the argument. Make sure to specify the parameter in the function signature.

Note: don't put '$' in the URL, replace $user_id with the actual id number. I really recommend reading the CI documentation on routing, you really need to have a good understanding of it to use CI properly. http://ellislab.com/codeigniter/user-guide/general/routing.html

Autres conseils

Try this:

echo anchor('test/anchor/?userid='. $user_id, 'Full View', 'class="ajax"');
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top