Not getting Get Variables form Url |
[eluser]kalpesh[/eluser]
Hi, I try to get variables from Url which like as follow http://localhost/Site/index.php/Offer?City=NewYork&Id=1 and try to print that variables Code: $data['city']=$_GET['City']; But I get this error: Code: A PHP Error was encountered I am just new in CI. So please Help me. Thanks.
[eluser]pistolPete[/eluser]
User guide: Quote:GET data is simply disallowed by CodeIgniter since the system utilizes URI segments rather than traditional URL query strings (unless you have the query string option enabled in your config file). The global GET array is unset by the Input class during system initialization.
[eluser]xwero[/eluser]
The basics of using the GET global is to set the uri_protocol to PATH_INFO, PATH_INFO_ORG or REQUEST_URI. If you want to enable query strings globally you set enable_query_string to true, or if you only want to use it for a few methods you add following as the first line of the method Code: $_GET = parse_str($_SERVER['QUERY_STRING']);
[eluser]xwero[/eluser]
pistolPete your comment is not really helpful as as you see from my response it's very easy to circumvent the GET destruction of CI.
[eluser]pistolPete[/eluser]
Well, kalpesh said he is new to CI. That's why I thougt I'd show him how CI usually handles URL parameter. It did not seem to be required to use GET variables, he only wanted to pass some parameters to his controller. |
Welcome Guest, Not a member yet? Register Sign In |