1

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.

10
  • Could it be there's some kind of redirection in between the two pages and that's how the POST information gets lost? The only thing that looks odd is the name of the view - test.php. Commented Jan 26, 2015 at 1:39
  • is there anyway i can test that and is so put a stop to it? Commented Jan 26, 2015 at 1:41
  • I think so, try Dev Tools -> Network... set it to preserve logs... and see what happens when you submit the form. Commented Jan 26, 2015 at 1:42
  • There we go. Check your routes and .htaccess. Test if it works with a different method name (instead of send). Commented Jan 26, 2015 at 1:47
  • Sounds like it could be a routing problem? Check your routes &/or .htaccess configuration to make sure everything is lining up. Commented Jan 26, 2015 at 1:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.