Welcome Guest, Not a member yet? Register   Sign In
Submit simple form don't work.
#1

[eluser]Marcone Ramos[/eluser]
I am following a tutorial about creating a simple login form. All I know is that nothing happens when I submit the form. It loads the same page, like the submit had no effect.
Can you guys help me please? I just can't see what's wrong.

the controller:
Code:
class C_loginsyslogin extends CI_Controller{
    
    //creating the index, the default function in my class
    
    function index() {
        
        
        //Load Libraries
        $this->load->library(array('encrypt', 'form_validation', 'session'));
        // LOAD HELPERS
        $this->load->helper(array('form', 'url'));

        // VALID USER CREDENTIALS
        $user_credentials = array();
        $user_credentials['testuser1'] = array(
            'user_name' => 'testuser1',
            'user_pass' => 'Gag/R6LlMz8JKhjd+pkMrL+MUIHn86vjs/ZJ31uH+QRCh1eRxxA0Fve6FXfE7rmFqgqsiwe2ZFrFT8ylZs050A==' // password
        );
        $user_credentials['testuser2'] = array(
            'user_name' => 'testuser2',
            'user_pass' => 'Gag/R6LlMz8JKhjd+pkMrL+MUIHn86vjs/ZJ31uH+QRCh1eRxxA0Fve6FXfE7rmFqgqsiwe2ZFrFT8ylZs050A==' // password
        );
        $user_credentials['testuser3'] = array(
            'user_name' => 'testuser3',
            'user_pass' => 'Gag/R6LlMz8JKhjd+pkMrL+MUIHn86vjs/ZJ31uH+QRCh1eRxxA0Fve6FXfE7rmFqgqsiwe2ZFrFT8ylZs050A==' // password
        );
        //---------------- SUBMISSION --------------------
                                //set_rules(THE NAME OF THE FIELD, THE NAME THAT USER SHOULD SEE THEM, IF IT'S REQUIRED OR NOT);
        $this->form_validation->set_rules('txtusername','User Name','required');
        $this->form_validation->set_rules('txtpassword','Password','required');
        
        //--------------- VALIDATING --------------------
        
        // has the form been submitted and with valid form info (not empty values)
        
        if($this->input->post('bntEnter'))
        {
        echo 'para';
        exit;
            if($this->form_validation->run())
            {
                $user_name = $this->input->post('txtusername');
                $user_pass = $this->input->post('txtpassword');
        
                if(array_key_exists($user_name, $user_credentials))
                {
                    // continue processing form (validate password)
                }
                else
                {
                    $this->session->set_flashdata('message', 'A user does not exist for the username specified.');
                    redirect('c_/index/');
                }
            }
        }
        //-----------------END VALIDATING ---------------
        //----------------- END SUBMISSION ------------
        $loadTemp["varContent"]="v_loginsyslogin";
        $this->load->view('v_admintemplate', $loadTemp);
    }
}

the view file
Code:
<?php if($this->session->flashdata('message')) : ?>
    <p>&lt;?=$this->session->flashdata('message')?&gt;</p>
&lt;?php endif; ?&gt;

&lt;? $attributes=array('name' => 'formLogin','class' => 'formLogin', 'enctype' => 'application/x-www-form-urlencoded'); ?&gt;
&lt;?=form_open('c_loginsyslogin/index/', $attributes)?&gt;
        <p>Por favor, identifique-se:</p>

        <p>
            &lt;?=form_label('Login:', 'user_name')?&gt;
            &lt;?
            //echo form_error("txtusername");
            $formBuildingData= array(
                'type' => "text",
                'name' => "txtusername",
                'class' => "normalText",
                'size' => "25"
                );
            ?&gt;
            &lt;?=form_input($formBuildingData)?&gt;
        </p>

        <p>
            &lt;?=form_label('Senha:', 'user_pass')?&gt;
            &lt;?
            //echo form_error("txtpasswordd");
             $formBuildingData2= array(
                'type' => "password",
                'name'=> "txtpassword",
                'class' => "normalText",
                'size' => "25"
            );
            ?&gt;
            &lt;?=form_password($formBuildingData2)?&gt;
        </p>

        <p>
            &lt;?
            $formBuildingData3=array(
            'type' => "submit",
            'name' => "bntEnter",
            'class'=> "buttonNormal",
            'value'=> "Entrar"
            );
            ?&gt;
            &lt;?=form_submit($formBuildingData3)?&gt;
        </p>

&lt;?=form_close();?&gt;

config
Code:
$config['index_page'] = 'index.php';


Messages In This Thread
Submit simple form don't work. - by El Forum - 05-09-2011, 12:24 AM
Submit simple form don't work. - by El Forum - 05-09-2011, 05:12 AM
Submit simple form don't work. - by El Forum - 05-09-2011, 12:09 PM
Submit simple form don't work. - by El Forum - 05-11-2011, 11:33 AM
Submit simple form don't work. - by El Forum - 05-11-2011, 01:15 PM
Submit simple form don't work. - by El Forum - 05-11-2011, 02:07 PM
Submit simple form don't work. - by El Forum - 05-13-2011, 09:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB