$ this-> input-> post () always returns FALSE, due to an unwanted 301

I am working on a registration page in CodeIgniter. The problem is that my message data does not go through . The following code always produces "fail":

class Signup extends CI_Controller {

    function index()
    {    
        if ($this->input->post())
        {
            echo 'success'; 
        }
        else
        {
            echo 'fail';

            echo form_open('signup');

            echo form_input('username', 'Username');
            echo form_input('email_address', 'Email address');
            echo form_submit('submit', 'Create Acccount');

            echo form_close();
        }
    }

}

What could be the problem?

To make it even more interesting, the form works fine on my localhost. This is when on a remote server when it fails.


Update 1: As requested, this is what the server outputs: (I closed the URL, I did not open it)

<form accept-charset="utf-8" method="post" action="http://www.url.com/signup">
<input type="text" value="Username" name="username">
<input type="text" value="Email address" name="email_address">
<input type="submit" value="Create Account" name="submit">
</form>

2: : (cmd R F5) . , , URL- ?


3: , 301. ( ). , . -, , post() false.

, - , 301'd?


4:. CodeIgniter, base_url http://www.url.com http://url.com

!:)

+3
4

301 ( HTTP-) . Firefox, TamperData. , , http://www.url.com/signup .

HTTP Location http://url.com/signup ( www), http://url.com/signup . , , . /signup.

+3

CI ? CI $this->input->post()

post() get() , .

; CI Reactor .

$_ POST . $this->input->post , :

$this->input->post() _fetch_from_array()

function _fetch_from_array(&$array, $index = '', $xss_clean = FALSE)
{
    if ( ! isset($array[$index]))
    {
        return FALSE;
    }

:

    if ($index === NULL AND ! empty($_POST))
    {
        $post = array();

        // Loop through the full _POST array and return it
        foreach (array_keys($_POST) as $key)
        {
            $post[$key] = $this->_fetch_from_array($_POST, $key, $xss_clean);
        }
        return $post;
    }

, post, .

+2

I would start with print_r (), using the $ _POST / $ _ REQUEST superglobals to see if PHP is seeing anything. This should help narrow it down to find out if there is a problem with PHP or CI.

0
source

I had this problem, this is a strange solution that I can’t explain, but that’s what worked. Do not use html for the form to use the code form. I tried it both ways and for some reason

$this->input->post('your_variable'); 

only works when using a form class, see codeigniter userguide

0
source

All Articles