Codeigniter $this->input->post() empty while $_POST is working correctly

前端 未结 13 1335
我在风中等你
我在风中等你 2020-12-05 14:56

On a codeigniter installation, I am trying to use the inbuilt $this->input->post(\'some_data\') function, however $this->input->post()

相关标签:
13条回答
  • 2020-12-05 15:03

    Upgrading from 2.2.x to 3.0.x -- reason post method fails. If you are upgrading CI 3.x, need to keep the index_page in config file. Also check the .htaccess file for mod_rewrite. CI_3.x

    $config['index_page'] = ''; // ci 2.x
    $config['index_page'] = 'index.php'; // ci 3.x
    

    My .htaccess

    <IfModule mod_rewrite.c>
     RewriteEngine On
     RewriteBase /
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteRule . /index.php [L]
    </IfModule>
    
    <IfModule !mod_rewrite.c>
     ErrorDocument 404 /index.php
    </IfModule>
    
    0 讨论(0)
  • 2020-12-05 15:03

    Finally got the issue resolved today. The issue was with the .htaccess file.

    Learning to myself: MUST READ THE CODEIGNITER DOCUMENTATION more thoroughly.

    0 讨论(0)
  • 2020-12-05 15:05

    To use $this->input->post() initialize the form helper. You could do that by default in config.

    0 讨论(0)
  • 2020-12-05 15:06

    Change your form action,

    From this:

    <form method="post" action="<?=base_url()?>yourprocess">
    

    Into this:

    <form method="post" action="<?=base_url()?>index.php/yourprocess">
    

    Basically, you just need to add "index.php" after your base_url():

    action="http://www.yourdomain.com/index.php/yourprocess"

    0 讨论(0)
  • 2020-12-05 15:10

    My issue was with an ajax call. I was using this:

    type: 'posts',

    instead of

    type: 'post',

    Syntax, D'oh!

    0 讨论(0)
  • 2020-12-05 15:12

    Solved as follows:

    Does the following exclude the redirection that is .htacess that will run the $ this-> input- > post ('name' ) on the controller, in my case it worked perfectly .

    abs, José Camargo]

    0 讨论(0)
提交回复
热议问题