开发者

Getting $_GET data in codeigniter while using REQUEST_URI

开发者 https://www.devze.com 2023-02-18 21:48 出处:网络
I am using CodeIgniter. In my script, I am changing $config[\'index_page\'] in config.php file as per the user\'s reponse, i.e, dynamic index_page is used. In order to get it work, I have changed the

I am using CodeIgniter. In my script, I am changing $config['index_page'] in config.php file as per the user's reponse, i.e, dynamic index_page is used. In order to get it work, I have changed the $config['uri_protocol'] value to "AUTO". Everything is working fine except when the case comes like : domain.com/index_page/auth/register?testvar=1 开发者_如何学编程It's not accepting the get variables and "PAGE NOT FOUND" error is there. I have tried several things already discussed here, but they involve changing the uri_protocol to "PATH_INFO" that I can't change as the site stops working. It requires "REQUEST_URI" to work properly which is exactly the case with "AUTO" setting.

So is there, any way to get it working??? Any help would be appreciated.


Have a look at this answer: Handling question mark in url in codeigniter it will require you to override the core URI class whenever you are accepting QUERY_STRING and inject your logic there.


Have you read this: http://codeigniter.com/user_guide/general/urls.html ? You pass vars like this: domain.com/index_page/auth/register/1

The first segment represents the controller class that should be invoked. The second segment represents the class function, or method, that should be called. The third, and any additional segments, represent the ID and any variables that will be passed to the controller.

Also you can do it your way, read the reference. But than why to use a framework at all?


I've done the same thing in my project and I got the url like

mydomain.com/search/?name=Arun+David&age=23

To achieve this,

In config file set

$config['uri_protocol']='PATH_INFO'; or $config['uri_protocol']='ORIG_PATH_INFO';

if PATH_INFO is not working try using ORIG_PATH_INFO. For me in localhost PATH_INFO is woking but not ORIG_PATH_INFO but while uploading it in server ORIG_PATH_INFO in working but not PATH_INFO.

and in your search controller's constructer add

parse_str($_SERVER['QUERY_STRING'],$_GET);

then you can use $_GET['name'] and $_GET['age'] in your code!.!. :-)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号