Codeigniter Post variable empty

2019-06-07 09:47发布

问题:

I have developed a few CI applications before and never had this issue before, but am still relatively new to it, and was trying to setup ION Auth with no luck so I narrowed it down to the $_POST being empty, so I've tried a fresh clean install and did this very simple test:

I've tried switching on and off CSRF & XSS as well as all the different URI protocals, as well as with a .htaccess file and without

Controller:

class Welcome extends CI_Controller {

public function index()
{
    $this->load->view('welcome_message');
}

public function send()
{
    $this->load->view('test.php', array('form_data' => $this->input->post('mysubmit')));
}
}

Added this to welcome_message view:

<?php echo form_open('welcome/send'); ?>
<?php echo form_submit('mysubmit', 'Submit Post!'); ?>
<?php echo form_close(); ?>

Did inspect element on chrome to look at the form, looks fine to me:

form action="http://www.myactualdomain.com/book/index.php/welcome/send" method="post" accept-charset="utf-8"

This is the code for test.php view:

Data: <?php echo $form_data; ?>

this returns: "Data:"

So I added to index.php at the top:

<?php
print "CONTENT_TYPE: " . $_SERVER['CONTENT_TYPE'] . "<BR />";
$data = file_get_contents('php://input');
print "DATA: <pre>";
var_dump($data);
var_dump($_POST);
print "</pre>";
?>

This returned:

CONTENT_TYPE: 
DATA:
string(0) ""
array(0) {
}

I tested the server outside of CI and it was fine, I ran this test:

<?php
print "CONTENT_TYPE: " . $_SERVER['CONTENT_TYPE'] . "<BR />";
$data = file_get_contents('php://input');
print "DATA: <pre>";
var_dump($data);
var_dump($_POST);
print "</pre>";
?>
<form method="post">
<input type="text" name="name" value="ok" />
<input type="submit" name="submit" value="submit" />
</form>

this is the result:

string(21) "name=ok&submit=submit"
array(2) {
["name"]=>
string(2) "ok"
["submit"]=>
string(6) "submit"
}

Form helper is auto loaded

Its an apache server running: PHP Version 5.3.3

Here is the post max size variable: post_max_size 64M 64M

Am I completely missing something??

Resolved

The issue was in config.php turns out taking away the www. in the base URL fixed the problem.