简体   繁体   English

在锚点代码点火器中转义禁止字符

[英]escaping forbidden character in anchor codeigniter

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. 原因是,当您单击“完整视图”链接时,模式会打开,并根据ID从我的数据库中显示不同的内容。 Codeigniter will not let me pass $userid since $ is a forbidden character. Codeigniter不允许我传递$ userid,因为$是一个禁止字符。 Is there anyway to get round this obstacle without enabling $ in 无论如何,在不启用$ in的情况下可以绕过此障碍

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

adding $ in the config would open up my application to sql injections right? 在配置中添加$将打开我的应用程序进行sql注入,对吗?

So basicly what I wish to achieve is to pass the ID from my view my modal window (that allso is a view) 因此,基本上,我希望实现的是从我的模态窗口的视图中传递ID(这就是一个视图)

Add the route to the routes.php config file 将路由添加到routes.php配置文件

    $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. 它将使用$ user_id作为参数调用您的函数。 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. 注意:请勿在网址中添加“ $”,而应将$ user_id替换为实际的ID号。 I really recommend reading the CI documentation on routing, you really need to have a good understanding of it to use CI properly. 我真的建议您阅读有关路由的CI文档,您确实需要对它有一个很好的了解,才能正确使用CI。 http://ellislab.com/codeigniter/user-guide/general/routing.html http://ellislab.com/codeigniter/user-guide/general/routing.html

尝试这个:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM