Isset does not work

Asked

Viewed 163 times

1

Good afternoon.

I’m making a shared racing web app, like "Uber".

I want you to present a list of registered drivers in the bank on the green carousel.

inserir a descrição da imagem aqui

However, as the image shows, my isset does not seem to be working, it already shows me all connection with bank, and I do not know how to solve.

This is my connection to the bank:

<div>
<? php
    if(isset($_POST['cpf'])){
        echo "<table>";
            echo "<tr>";
                echo "<th>NOME</th>";
                echo "<th>DISPONIBILIDADE</th>";
                echo "<th>CARRO</th>";
                echo "<th>CPF</th>";
                echo "<th>DATA DE NASCIMENTO</th>";
                echo "<th>SEXO</th>";
            echo "</tr>";

            $strcon = mysqli_connect('localhost', 'root', '') or die('Erro ao conectar ao banco de dados');
            mysqli_select_db($strcon, 'uber');
            $sql = "SELECT nome, disponibilidade, carro, cpf, nascimento, sexo FROM tb_motorista WHERE cpf = $_POST[cpf]";
            $resultado = mysqli_query($strcon,$sql) or die("Erro ao retornar dados");

            while ($registro = mysqli_fetch_array($resultado)) {
                $nome = $registro['nome'];
                $disponibilidade = $registro['disponibilidade'];
                $carro = $registro['carro'];
                $cpf = $registro['cpf'];
                $nascimento = $registro['nascimento'];
                $sexo = $registro['sexo'];
                echo "<tr>";
                    echo "<td>".$nome."</td>";
                    echo "<td>".$disponibilidade."</td>";
                    echo "<td>".$carro."</td>";
                    echo "<td>".$cpf."</td>";
                    echo "<td>".$nascimento."</td>";
                    echo "<td>".$sexo."</td>";
                echo "</tr>";
            }
            mysqli_close($strcon);
        echo "</table>";
    }else{
        echo 'Motra a lista de Motoristas';
    }
?>
</div>

The green carousel code, which I put the bank include:

<div class="carousel carousel-slider center" data-indicators="true" style="height: 480px;">
<div class="carousel-fixed-item center">
<a class="btn waves-effect white teal-text darken-text-2">Excluir</a>
</div>
<div class="carousel-item teal white-text" href="#one!">
<h2>Lista de Corridas</h2>
<p class="white-text"><div id="cons_motoca"><?php include("componentes/cons_motoca.php"); ?></div></p>
</div>
</div>

And the index, which has the carousel include:

<?php include("componentes/header.php"); ?>

<div class="row">
<div class="col s4" style="">
    <div class="card">
        <div class="card-tabs">
            <ul class="tabs tabs-fixed-width">
                <li class="tab"><a href="#corridas" style="color: teal">Corridas</a></li>
                <li class="tab"><a href="#motorista" class="active" style="color: teal">Motorista</a></li>
                <li class="tab"><a href="#passageiro" style="color: teal">Passageiros</a></li>
            </ul>
        </div>
        <div class="card-content white lighten-4">
            <?php include("componentes/corrida.php"); ?>
            <?php include("componentes/motorista.php"); ?>
            <?php include("componentes/passageiro.php"); ?>
        </div>
    </div>
</div>
<div class="col s8">
<?php include("componentes/view.php"); ?>
</div>
</div>


<?php include("componentes/footer.php"); ?>
  • isset in Post Data "work" as it is a set array. It would be better if all content were inserted into variables and tested with empty.

1 answer

4


In this file here:

<div>
<? php // <<<<<<<<
    if(isset($_POST['cpf'])){
        echo "<table>";
            echo "<tr>";
                echo "<th>NOME</th>";
//...
</div>

the php opening tag should be

<?php 
    // codigo
?>
  • Happens in the best families.. hehehehe +1

  • I WANT TO KILL MYSELF!!! HSUAHSAUHSAUSHAUSHAUSHAUHS

Browser other questions tagged

You are not signed in. Login or sign up in order to post.