• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
2 $this->input->post :one is empty and the other returns ok

#1
I have 2 simple and identical files (logically writing to different tables). They use forms to register 2 and 3 values using inputs. But one is returning empty. I already checked if the path is pointing to the file where I write to the bank. (yes, it's going to the right file, because I put print_r () and die ().
Returns the ok array
PHP Code:
    <main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-4">
        <
div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
            <
div class="col-md-12">
            <
h1 class="h2">Nova Disciplina</h1>
            </
div>
        </
div>
    
    <form  class="needs-validation" novalidate action="<?php echo base_url();?>disciplina/cadastrar" method="post">
            <
div class="form-row">
                <
div class="col-md-6 mb-3">
                <
label for="cnomemat" class="control-label">Nome da Disciplina</label>
                <
input type="text" class="form-control" id="cnomemat" name="cnomemat" placeholder="Nome" required>
                <
div class="invalid-feedback">
                      Nome da Disciplina é obrigatório !
                </div>
            
  </div>
            
  <div class="col-md-6 mb-3">
                <
label for="cabrev" class="control-label">Nome Abreviado</label>
                <
input type="text" class="form-control" id="cabrev" name="cabrev" placeholder="Nome Abreviado 10 caracteres" required>
                <
div class="invalid-feedback">
                      Abreviação da Disciplina é obrigatório !
                </div>
            
  </div>
            </
div>  
             
<div style="text-align:right">
                <
button type="submit" class="btn btn-primary">Gravar</button>
                <?= 
anchor('disciplina/7''Cancelar', array('class' => 'btn btn-danger')); ?>
              </div>
        </form>
        <script type="text/javascript">
        
        </script>    
    </main> 
Returns empty

PHP Code:
    <main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-4">
        <
div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
            <
div class="col-md-12">
            <
h1 class="h2">Nova Turma</h1>
            </
div>
        </
div>
         <
form class="needs-validation" novalidate action="<?php echo base_url();?>turma/cadastrar" method="post">
             <
div class="form-row">
                <
div class="col-md-4 mb-3">
                
  <label for="cnometur">Nome da Turma</label>
                
  <input type="text" class="form-control" id="cnometur" name="cnometur "placeholder="Nome da Turma" value=""required>
                
  <div class="invalid-feedback">
                      Numero da Turma é obrigatório !
                </div>
                </
div>
                <
div class="col-md-4 mb-3">
                
  <label for="cletivo">Ano letivo</label>
                
  <input type="text" class="form-control" id="cletivo" name="cletivo "placeholder="Ano Letivo" value=""required>
                
  <div class="invalid-feedback">
                      Ano Letivo é obrigatório !
                </div>
                </
div>
                <
div class="col-md-4 mb-3">
                
  <label for="csemestre2">Semestre</label>
                
  <input type="text" class="form-control" id="csemestre2" name="csemestre2 "placeholder="Semestre" value=""required>
                
  <div class="invalid-feedback">
                      Semestre é obrigatório !
                </div>
                </
div>
            </
div>
            
  <div style="text-align:right">
                <
button type="submit" class="btn btn-primary">Gravar</button>
                <?= 
anchor('turma/alertar/500''Cancelar', array('class' => 'btn btn-danger')); ?>
              </div>
        </form>
    </main> 

It works
PHP Code:
    function cadastrar()
    {
        print_r($this->input->post('cnomemat'));
        
print_r($this->input->post('cabrev'));
        die();                
        
$data['CNOMEMAT']=$this->input->post('cnomemat');
        
$data['CABREV']=$this->input->post('cabrev'); 

Empty
PHP Code:
  public function cadastrar()
    {
        
print_r($this->input->post('cnometur'));
        
print_r($this->input->post('cletivo'));
        
print_r($this->input->post('csemestre'));
        die();
        
$data['NTURMA']=$this->input->post('cnometur');
        
$data['CLETIVO']=$this->input->post('cletivo');
        
$data['CSEMESTRE']=$this->input->post('csemestre'); 
Reply

#2
Maybe because you have spaces at the wrong places (name and value) :

Code:
<input type="text" class="form-control" id="cnometur" name="cnometur "placeholder="Nome da Turma" value=""required>

Should be:

Code:
<input type="text" class="form-control" id="cnometur" name="cnometur" placeholder="Nome da Turma" value="" required>
Test your translation files with Translation Tester
Reply

#3
(03-24-2020, 02:11 PM)includebeer Wrote: Maybe because you have spaces at the wrong places (name and value) :

Code:
<input type="text" class="form-control" id="cnometur" name="cnometur "placeholder="Nome da Turma" value=""required>

Should be:

Code:
<input type="text" class="form-control" id="cnometur" name="cnometur" placeholder="Nome da Turma" value="" required>

OHHHH..my god! Many days of home office, stressed ... and that was exactly the mistake! A space at the end .... kkkkkkkk

THANK YOU !
Reply

#4
Haha! That’s funny but very frustrating when it happens! Glad it’s working now!
Test your translation files with Translation Tester
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.