CodeIgniter form_open_multipart, how to use

2

I'm using CodeIgniter in a project but I'm having a hard time sending information, I have a view that contains a form with the registration fields:                             

            <?php

             echo form_open_multipart('Controller_site/cadastro_form');

             ?>

            <input type="text" class="input-text" name="pais" placeholder="País">

        </div>
    </div>
</div>

In this view I have several other fields that are being "wrapped" with divs (Bootstrap) to assemble the layout. I'm closing the form in the last div:

 <div class="row">
<div class="col-md-12" align="center">

    <button type="button" class="btn btn-success">Cadastrar</button>

    <?php
     echo form_close();

     ?>

</div>

In the Controller_site I have the following function:

 public function cadastro_form(){


    $data = 'null';


        $data = array(
            'pais' => $this->input->post('pais'),
            'name_users' => $this->input->post('name_users'),
            'last_name' => $this->input->post('last_name'),
            'date_nasc' => $this->input->post('date_nasc'),
            'sexo' => $this->input->post('sexo'),
            'cpf' => $this->input->post('cpf'),
            'mail' => $this->input->post('mail'),
            'phone' => $this->input->post('phone'),
            'cep' => $this->input->post('cep'),
            'logradouro' => $this->input->post('logradouro'),
            'bairro' => $this->input->post('bairro'),
            'num' => $this->input->post('num'),
            'city' => $this->input->post('city'),
            'state' => $this->input->post('state'),
            'payment' => $this->input->post('payment'),
            'num_cart' => $this->input->post('num_cart'),
            'validade' => $this->input->post('validade'),
            'agencia' => $this->input->post('agencia'),
            'conta' => $this->input->post('conta'),
            'cvv' => $this->input->post('cvv'),
            'login' => $this->input->post('login'),
            'senha' => $this->input->post('senha'),
            'confirmar_senha' => $this->input->post('confirmar_senha'),





        );


        $this->Model_site->cadastro($data);

        redirect("index", 'redirect');


    }
}

No model:      public function register ($ data) {

    return $this->db->insert('tb_users',$data);
}
} 

I fill in the form data and nothing happens the page stays the same way the "looks" button does not have a button effect.

Note: The database file is already configured.

    
asked by anonymous 26.11.2018 / 12:51

1 answer

5

The problem is that you have

<button type="button" class="btn btn-success">Cadastrar</button>

The <button> element with type="button" does not submit the form. It is most commonly used when you are going to make an AJAX request or perform some action on the page itself.

To submit the form, change to type="submit" :

<button type="submit" class="btn btn-success">Cadastrar</button>
    
26.11.2018 / 12:58