Welcome Guest, Not a member yet? Register   Sign In
Get and Post wont work ?
#1

[eluser]DJMOHNL[/eluser]
I have some trouble getting $this->input->post() and $this->input->get() getting to work.
As i have developed multiple websites with CI and never had this problem. If i put a get string inside the URL (browser addressbar) CI shows a 404 error.

The config query strings are enabled,
my .htacces is as followed:
Code:
RewriteEngine On
    RewriteBase /
      
    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    
    # redirect /index.php/controllername/ to /controllername/function/
    RewriteRule ^(.*)$ /index.php/$1 [QSA]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
$config['uri_protocol'] = "AUTO";
$config['enable_query_strings'] = TRUE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
$config['directory_trigger'] = 'd'; // experimental not currently in use
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';

i need to have both uri strings and segment to be connected to eachother.
like: http://site.ext/controller/method/?key=something

it worked before with other websites (same hosting and other hosting)
-> recently updated all plesk modules(applications)

i dont know what the cause of this problem is, cant find anything on google nor ci forums.
Tried everything on the forums about _GET and mod_rewrite nothing worked
aso i have:
Code:
function _remap($method)
{
    if (method_exists($this, $method))
    {
        $this->$method($this->uri->segment(3));
    }
    else
    {
        $this->index($method);
    }
}

Can someone hep me out here ? (its for the OpenSource Projects)
thanks!
#2

[eluser]WanWizard[/eluser]
CI supports routing by URI segments (if 'enable_query_strings' is FALSE), or by query string parameters (if 'enable_query_strings' is TRUE).
You can't have both in the default setup, when using URI segment routing, CI will strip and remove the query string.

Use the search option of find a workaround for this, this has been discussed many times. (hint: search for 'allow_get_array').
#3

[eluser]DJMOHNL[/eluser]
[quote author="WanWizard" date="1280347900"]CI supports routing by URI segments (if 'enable_query_strings' is FALSE), or by query string parameters (if 'enable_query_strings' is TRUE).
You can't have both in the default setup, when using URI segment routing, CI will strip and remove the query string.

Use the search option of find a workaround for this, this has been discussed many times. (hint: search for 'allow_get_array').[/quote]


yo, my problem is i cant get any post or get parameters send by a form ...
normally it does work, but now it doesnt work ... i cant seem to find why and there nothing on this forum that tells me how i should solve this.

About the query strings, ITS not working eighter a form with method="get" doesnt work, even when query strings are enabled, disabled of if my
Code:
$config['uri_protocol']    = "AUTO";
is set to anything else (i mean tested all none working!)
#4

[eluser]WanWizard[/eluser]
Check the manual.

If you enable query strings, you enable them for routing only. CI will expect a query string like http://www.example.org?c=controller&m=method, and not every method of helper supports this (they expect URI segments). Enable query string doesn't mean "allow all possible query strings to work".

The fact that posts don't work is probably related to you enabling query strings as well, as that will disable segment routing so none of your controllers will be accesable anymore...
#5

[eluser]DJMOHNL[/eluser]
this cant be, ive had urls like: http://mysite.ext/controller/method?getv...rrr&z=ijsf

it worked before, i dont know why it wont work now.
Also when i submit my form with method get, it doesnt append the get vars to the url (or get stripped by something) and when the form method is set to post and i try $this->input->post('thenameofthevar') it wont work..

Really dont know why my get and post wont work. if i put a get var to my url i cant extract it with the $this->input->get('thenameofvar') it wont work...

I really need this website to be up an running soon, its an OpenSource Project but some of my php settings might be doing this or ?
#6

[eluser]DJMOHNL[/eluser]
also i dont want to use: http://www.example.org?c=controller&m=method
but http://www.example.org/controller/method...s=getparam
#7

[eluser]pbreit[/eluser]
Querystrings are minimally supported in CodeIgniter. Look here for some solutions: http://ellislab.com/forums/viewthread/159382/

And register your vote for proper querystring support in CodeIgniter!
#8

[eluser]WanWizard[/eluser]
[quote author="DJMOHNL" date="1280435783"]this cant be, ive had urls like: http://mysite.ext/controller/method?getv...rrr&z=ijsf
it worked before, i dont know why it wont work now.[/quote]
Not with standard CI you didn't. Unless you have some code that parsed $_SERVER['QUERY_STRING'], because that should still be available.

[quote author="DJMOHNL" date="1280435783"]Also when i submit my form with method get, it doesnt append the get vars to the url (or get stripped by something)...[/quote]
I've already explained this, but if you don't read... We're only trying to help. If you don't want our help, just say so...
#9

[eluser]DJMOHNL[/eluser]
on my log it tells me:
Code:
DEBUG - 29-07-2010 20:45:42 --> Config Class Initialized
DEBUG - 29-07-2010 20:45:42 --> Hooks Class Initialized
DEBUG - 29-07-2010 20:45:42 --> URI Class Initialized
DEBUG - 29-07-2010 20:45:42 --> Router Class Initialized
DEBUG - 29-07-2010 20:45:42 --> Output Class Initialized
DEBUG - 29-07-2010 20:45:42 --> Input Class Initialized
DEBUG - 29-07-2010 20:45:42 --> Global POST and COOKIE data sanitized
DEBUG - 29-07-2010 20:45:42 --> Language Class Initialized
DEBUG - 29-07-2010 20:45:42 --> Loader Class Initialized
DEBUG - 29-07-2010 20:45:42 --> Helper loaded: url_helper
DEBUG - 29-07-2010 20:45:42 --> Controller Class Initialized
DEBUG - 29-07-2010 20:45:42 --> File loaded: /var/www/vhosts/[domain*]/httpdocs/system/application/views/post/zoek_post.php
DEBUG - 29-07-2010 20:45:42 --> File loaded: /var/www/vhosts/[domain*]/httpdocs/system/application/views/site.php
DEBUG - 29-07-2010 20:45:42 --> Final output sent to browser
DEBUG - 29-07-2010 20:45:42 --> Total execution time: 0.0134

* edited for security reasons (it was my domain name in the log edited here)

it tells me this:
DEBUG - 29-07-2010 20:45:42 --> Global POST and COOKIE data sanitized
i cant seem to know what 'sanitized' means (google tells me in dutch its cleaned) and my
Code:
$config['global_xss_filtering'] = FALSE;
i cant get any post or get variables using:
Code:
$config['enable_query_strings'] = FALSE;
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-'; (maybe ? is needed?)

using this form:
Code:
<form method="get" action="zoek/">
                        <fieldset>
                            <legend>Uw plaats, postcode of regio</legend>
                            &lt;input type="text" id="key" value="" class="side" /&gt;
                            &lt;input type="submit" value="Doorgaan" class="side" /&gt;
                        </fieldset>
                    &lt;/form&gt;
and this code to get the parameters:
Code:
$keyword = $this->input->post('key');

if(!$keyword){
    $keyword = 'geen zoekopdracht gevonden.';
}

? i have read all above, none still working not even the CI 2 Get Parameters patch.
-> PHP Version 5.2.13
-> Apache 2.0 Handler
-> register_globals Off
-> safe_mode Off
-> always_populate_raw_post_data Off

apache and php (and everything arround) was updated a few days ago (before it know it was working with other domains (cant check it out unfortunately)
#10

[eluser]WanWizard[/eluser]
Which patch are you talking about? Mine, from the post @pbreit referred you to?

That should work like a charm, providing you have 'enable_query_strings' to FALSE, and 'allow_get_array' to TRUE.

If I test this here with the URL
Code:
http://test.catwoman.exite.local/en/homepage.html?foo=bar&bar=foo

it uses 'en/homepage' to route to the correct controller, and in that controller,
Code:
var_dump($_GET);
// gives me
//    array
//      'foo' => string 'bar' (length=3)
//      'bar' => string 'foo' (length=3)




Theme © iAndrew 2016 - Forum software by © MyBB