Welcome Guest, Not a member yet? Register   Sign In
CI Killing the $_POST variable
#1

[eluser]adamfairholm[/eluser]
This one has me scratching my head. I've got a form that is using post to submit some data. Really simple form, just a text field. However, when I submit, nothing happens - just a page refresh.

A quick print_r of the $_POST variable tells me that its not getting anything. It's just an empty array. Same with using the $this->input->post() function.

However, if I make a test.php file outside of the CI structure and do a quick $_POST test, it works as expected.

The CI exclusivity makes me think its not a server config issue, but something to do with CI. Has anyone ever run into this before? I haven't so I'm drawing a blank on where to even start.

Here is the code below. Like I said, it's very simple.

Controller:

Code:
function index()
    {
        print_r($_POST);
    
        if( isset($_POST) && ! empty($_POST) )
        {
                    //Do some stuff here
        }
    
        $this->load->view('placeholder', $this->data);
    }

View:

Code:
<form action="<?=$link_url;?>main" method="post">
                    
                    <p>&lt;input type="text" name="email_address" /&gt; &lt;input type="submit" name="Submit" id="submit_button" /&gt;&lt;/p>
                &lt;/form&gt;
#2

[eluser]adamfairholm[/eluser]
After upgrading to the latest version of CI, it still didn't solve the problem. However, I started new with a new install of CI after wiping the filesystem clean and that did the trick. I still don't know, what happened - I just copied the code over to the new system and it worked - but its fixed now so I guess chalk it up to goblins. SOLVED.
#3

[eluser]HarishKumar[/eluser]
Hi
I think there is a problem in your action.Try the following

&lt;?php echo form_open('main');?&gt;
<p>&lt;input type="text" name="email_address" /&gt; &lt;input type="submit" name="Submit" id="submit_button" /&gt;&lt;/p>
&lt;?php form_close();?&gt;

OR

&lt;form action="&lt;?php echo base_url().'main'?&gt;" method="post"&gt;

<p>&lt;input type="text" name="email_address" /&gt; &lt;input type="submit" name="Submit" id="submit_button" /&gt;&lt;/p>
&lt;/form&gt;

Both will be working.Try it out




Theme © iAndrew 2016 - Forum software by © MyBB