Welcome Guest, Not a member yet? Register   Sign In
CI clears the complete input?
#1

[eluser]Unknown[/eluser]
Hello!

Could anybody give me a solution for my current problem:

I'm working with CI for the first time (I'm not a PHP noob but CI is new to me. A customer wants to have it for a project so I have to work with it ;-)) and it makes me crazy.

Currently I'm builing the login page for the project and CI clears the complete input Arrays (I know it should clear the GET-Array). The POST-Array and $this->input... are empty, too.

Everything seems to work well. I can create controllers and views, fetch and store data from/to the database and so on.

At first the input and post features were working, but after adding the following (really simple) html-basement the issue starts.

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
    &lt;head&gt;
        &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;

        &lt;title&gt;Just a test&lt;/title&gt;
    &lt;/head&gt;

    &lt;body&gt;
                        &lt;form action="/new/user/login" method="post"&gt;

                            Login &lt;input type="text" value="Username" class="login" name="user" /&gt; &lt;input type="password" value="Password" class="login" name="pass" /&gt; &lt;input type="submit" name="Button" class="button" /&gt;
                        &lt;/form&gt;
    &lt;/body&gt;
&lt;/html&gt;


The form-builder isn't working with this, too.

To avoid this question:
I've added a simple
Code:
&lt;?php var_dump($_POST); ?&gt;
in front of the config-file and the post data is existent at the beginning. After running the first controller every information was cleared by CI :bug:.

Does anybody know a similar problem or can help my out of this situation?

At least there's nothing special to say about the current setup. It's based on a long time running fedora 9 root-webserver with apache 2.2 and the latest CI version.

Regards
#2

[eluser]steelaz[/eluser]
What do you get in "login" method when you call lines below?

Code:
$user = $this->input->post('user');
var_dump($user);
#3

[eluser]tomcode[/eluser]
What do You mean by :
[quote author="nonamez78" date="1275598736"]After running the first controller
[/quote]

You can run only one Controller. Do You redirect ?

If You redirect, then, of course, You loose the POST data.
#4

[eluser]pickupman[/eluser]
One the little gems hidden in the user guide is:
Code:
$this->output->enable_profiler(TRUE);

It will output your _REQUEST array, DB queries, and execution time. I usually put a conditional tag for logged in under a admin/dev credentials above, so only I will see it.

When using forms in CI, you want to make sure you are using the form validation class.
Code:
//In controller
$this->load->library('form_validation');
$this->load->helper('form');

$this->form_validation->set_rules('user','username', 'required|trim');
$this->form_validation->set_rules('pass','password', 'required|trim');

if($this->form_validation->run()){
//Do something here since form was filled in correctly
}else{
  //Load login form view
}

//In view you use the form helper to do the heavy lifting
Login
&lt;?=echo form_input( array('name' => 'user', 'class="login"'), set_value('user','Username'));?&gt;
&lt;?=echo form_password( array('name' => 'pass', 'class="login"'), set_value('pass','Password') );?&gt;

This will provide the default values, and repopulate fields on failed submission.




Theme © iAndrew 2016 - Forum software by © MyBB