Method Search for bank records on the same page as the PHP form

-1

Good morning, I'm working on a personal project and I plan to do a page to find clients informing their name and CPF for the time being the code is like this, but it's not working. Can someone tell me why?

Here is the code below

Page code / form part

            <form id="demo-form2" data-parsley-validate class="form-horizontal form-label-left" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">

                  <div class="form-group">
                    <label class="control-label col-md-1 col-sm-3 col-xs-12" for="first-name">Nome 
                    </label>
                    <div class="col-md-6 col-sm-6 col-xs-12">
                      <input type="text" id="first-name" name="nome" class="form-control col-md-7 col-xs-12">
                    </div>
                  </div>
                  <div class="form-group">
                        <label class="control-label col-md-1 col-sm-3 col-xs-12" for="last-name">CPF<span class="required">*</span>
                        </label>
                        <div class="col-md-3 col-sm-6 col-xs-12">
                          <input type="text" id="last-name" name="cpf" class="form-control col-md-3 col-xs-12">
                        </div>
                  </div>




                  <div class="ln_solid"></div>
                  <div class="form-group">
                    <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
                      <a href="index.html"><button class="btn btn-round btn-danger" type="button">Cancelar <span class="glyphicon glyphicon-remove-circle" aria-hidden="true"></span></button></a>
                      <button class="btn btn-round btn-warning" type="reset">Resetar <span class="glyphicon glyphicon-repeat" aria-hidden="true"></span></button>
                      <button type="submit" class="btn btn-round btn-primary">Buscar <span class="glyphicon glyphicon-search" aria-hidden="true"></span></button>
                    </div>
                  </div>

                </form>

Part of Listing Records

 <tbody>
                            <?php if(isset($_POST['submit'])): ?>
                            <?php foreach ($cliente->findClientes($nome,$cpf) as $key => $value): ?>
                              <tr class="even pointer">
                                <td class=" "><?php echo $value->id; ?></td>
                                <td class=" "><?php echo $value->nome; ?></td>
                                <td class=" "><?php echo $value->profissao; ?></td>
                                <td class="celula"><?php echo $value->endereco; ?></td>
                                <td class=" "><?php echo $value->numhab; ?></td>
                                <td class="telefone" style="width: 150px"><?php echo $value->telefone1; ?></td>
                                <td class="telefone" style="width: 150px"><?php echo $value->telefone2; ?></td>
                                <td class=" "><?php echo $value->bairro; ?></td>
                                <td class=" "><?php echo $value->cidade; ?></td>
                                <td class=" "><?php echo $value->uf; ?></td>
                                <td class=" "><?php echo $value->cep; ?></td>
                                <td class="cpf"><?php echo $value->cpf; ?></td>
                                <td class=" "><?php echo $value->email; ?></td>
                                <td class=" " style="text-align: center"><?php echo $value->usuario; ?></td>
                                <td class=" last" style="width: 100px"> <?php echo "<a href='condutores.php?id=" . $value->id . "'>Condutores <span class='glyphicon glyphicon-user' aria-hidden='true'></span></a> "; ?></td>
                                <td class=" last" style="width: 80px"> <?php echo "<a href='clientes.php?id=" . $value->id . "'>Editar <span class='glyphicon glyphicon-pencil' aria-hidden='true'></span></a> "; ?></td>
                                <td class=" last" style="width: 80px"> <?php echo "<a class='delete' href='../Controllers/deletarCliente.php?&id=" . $value->id . "' data-confirm-cliente='Deseja excluir este cliente? '>Excluir <span class='glyphicon glyphicon-remove' aria-hidden='true'></span></a> "; ?></td>
                              </tr>
                              <?php endforeach; ?>

                              <?php endif; ?>

                            <?php foreach ($cliente->findAll() as $key => $value): ?>
                              <tr class="even pointer">
                                <td class=" "><?php echo $value->id; ?></td>
                                <td class=" "><?php echo $value->nome; ?></td>
                                <td class=" "><?php echo $value->profissao; ?></td>
                                <td class="celula"><?php echo $value->endereco; ?></td>
                                <td class=" "><?php echo $value->numhab; ?></td>
                                <td class="telefone" style="width: 150px"><?php echo $value->telefone1; ?></td>
                                <td class="telefone" style="width: 150px"><?php echo $value->telefone2; ?></td>
                                <td class=" "><?php echo $value->bairro; ?></td>
                                <td class=" "><?php echo $value->cidade; ?></td>
                                <td class=" "><?php echo $value->uf; ?></td>
                                <td class=" "><?php echo $value->cep; ?></td>
                                <td class="cpf"><?php echo $value->cpf; ?></td>
                                <td class=" "><?php echo $value->email; ?></td>
                                <td class=" " style="text-align: center"><?php echo $value->usuario; ?></td>
                                <td class=" last" style="width: 100px"> <?php echo "<a href='condutores.php?id=" . $value->id . "'>Condutores <span class='glyphicon glyphicon-user' aria-hidden='true'></span></a> "; ?></td>
                                <td class=" last" style="width: 80px"> <?php echo "<a href='clientes.php?acao=editar&id=" . $value->id . "'>Editar <span class='glyphicon glyphicon-pencil' aria-hidden='true'></span></a> "; ?></td>
                                <td class=" last" style="width: 80px"> <?php echo "<a class='delete' href='../Controllers/deletarCliente.php?&id=" . $value->id . "' data-confirm-cliente='Deseja excluir este cliente? '>Excluir <span class='glyphicon glyphicon-remove' aria-hidden='true'></span></a> "; ?></td>
                              </tr>

                              <?php endforeach; ?>
                            </tbody>

Function Code findClients

 public function findClientes($nome,$cpf){

    $conexao = new Conexao();

    $sql = "SELECT * FROM $this->table WHERE nome LIKE '%:nome%' AND cpf LIKE '%:cpf%' ";

    return $conexao->select($sql, array(":nome" => $nome, ":cpf" => $cpf));
}

Thanks in advance for the help

    
asked by anonymous 18.09.2018 / 05:56

1 answer

1

You do not need to declare the function with public, just do this:

function findClientes($nome,$cpf){ 
...

}
    
18.09.2018 / 21:31