Welcome Guest, Not a member yet? Register   Sign In
New problem in $_GET due to removing index.php in CI 2.0.2
#1

[eluser]Ali Fattahi[/eluser]
Hello
after removing index.php in CI 2.0.2 And set uri_protocol to QUERY_STRING , i can't use $_GET in my project .
how can i solve this problem ?

Thanks
Ali
#2

[eluser]web-johnny[/eluser]
[quote author="Ali Fattahi" date="1307831208"]Hello
after removing index.php in CI 2.0.2 And set uri_protocol to QUERY_STRING , i can't use $_GET in my project .
how can i solve this problem ?

Thanks
Ali[/quote] Try to change the
Code:
$config['enable_query_strings'] = FALSE;
to
Code:
$config['enable_query_strings'] = TRUE;
at the config file of your codeigniter
#3

[eluser]Ali Fattahi[/eluser]
[quote author="web-johnny" date="1307929054"][quote author="Ali Fattahi" date="1307831208"]Hello
after removing index.php in CI 2.0.2 And set uri_protocol to QUERY_STRING , i can't use $_GET in my project .
how can i solve this problem ?

Thanks
Ali[/quote] Try to change the
Code:
$config['enable_query_strings'] = FALSE;
to
Code:
$config['enable_query_strings'] = TRUE;
at the config file of your codeigniter[/quote]

Thanks for reply ,
but i don't want to enable query string . there are any other way ?
Thanks
#4

[eluser]web-johnny[/eluser]
But this is the query string!!! To take the $_GET. Perhaps if you change it to your constructor like:
Code:
$this->config->set_item('enable_query_strings',false);
perhaps it works, try it...
#5

[eluser]Ben Swinburne[/eluser]
Presumably you have removed index.php from the config file because you're using clean URLs?

Could you post your .htaccess file contents please.
#6

[eluser]Ali Fattahi[/eluser]
[quote author="Ben Swinburne" date="1308075350"]Presumably you have removed index.php from the config file because you're using clean URLs?

Could you post your .htaccess file contents please.[/quote]

yes i have removed index.php in config.php

and the .htaccess content
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /SabaPay

    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>  

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>
#7

[eluser]Ali Fattahi[/eluser]
[quote author="web-johnny" date="1308065171"]But this is the query string!!! To take the $_GET. Perhaps if you change it to your constructor like:
Code:
$this->config->set_item('enable_query_strings',false);
perhaps it works, try it...[/quote]
Thanks , but i think it's not good way to to take $_GET ,i tested the way and it didn't works. Before i used $_GET Without query string but in version 2.0.2 it has problem Sad
#8

[eluser]Ali Fattahi[/eluser]
Hello
I Solved the problem Big Grin
in MY_Input i wrote the code :

Code:
function get($index = NULL, $xss_clean = FALSE)
{
    $query = parse_url($_SERVER['REQUEST_URI'],PHP_URL_QUERY);
    $query = split('&',$query);
    foreach ($query as $key=>$value)
    {
        $spl = split('=',$query[$key]);
        $res[$spl[0]] = $spl[1];
    }
    $_GET = $res;
    // Check if a field has been provided
    if ($index === NULL AND ! empty($_GET))
    {
        $get = array();
            // loop through the full _GET array
        foreach (array_keys($_GET) as $key)
        {
            $get[$key] = $this->_fetch_from_array($_GET, $key, $xss_clean);
        }
        return $get;
    }
        return $this->_fetch_from_array($_GET, $index, $xss_clean);
}
#9

[eluser]Ben Swinburne[/eluser]
Changing

Code:
RewriteRule ^(.*)$ index.php?/$1 [L]

To

Code:
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]

Might solve your problem rather than needing to extend CI_Input
#10

[eluser]Ali Fattahi[/eluser]
[quote author="Ben Swinburne" date="1308143786"]Changing

Code:
RewriteRule ^(.*)$ index.php?/$1 [L]

To

Code:
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]

Might solve your problem rather than needing to extend CI_Input[/quote]
Thanks for your answers .
After changing to [QSA,L] i got The "The URI you submitted has disallowed characters" messeage whereas the url have not any disallowed characters Smile

Best Wishes
Ali




Theme © iAndrew 2016 - Forum software by © MyBB