Connect form with database

0

I have Database called form, and a unique table n_acordos.

I need to display form information in a table. Not able to connect to database.

<?php
 $conn = mysqli_connect("localhost","root","","formulario");
 $sql = 'SELECT * FROM formulario';
 $resultado_formulario = mysqli_query($conn ,$sql);
 if($sql === FALSE) { 
   die(mysqli_error());
} 
  while($row = mysqli_fetch_assoc($resultado_formulario)) {
                    echo $row['n_acordos'];
                }

                mysqli_close($conn);
?>

<p style="text-align:center"><strong><span style="font-size:120px">
<span style="font-family:arial,helvetica,sans-serif">
<span style="color:#FFFF00">
<span style="background-color:#000000">ACORDOS FORMALIZADOS</span></span></span></span></strong></p>

<table align="center" border="1" cellpadding="1" cellspacing="1" style="width:450px">
    <tbody>

        <tr>
            <td rowspan="4" style="text-align:center"><strong><span style="color:#FFFFFF"><span style="font-size:450px"><span style="background-color:#000000"><?php $ntotalacordos=$_POST["f_total"]; echo $_POST['f_total']; ?></span></span></span></strong></td>
            <td colspan="2" style="text-align:center"><span style="color:#000000"><em><strong><span style="font-size:180px">Consultor</span></strong></em></span></td>
        </tr>



        <tr>
            <td style="text-align:center"><span style="color:#FF0000"><strong><span style="font-size:100px"><?php $ultimo=$_POST["f_ultimo"]; echo $_POST['f_ultimo'];
 ?></span></strong></span></td>
            <td><span style="font-family:tahoma,geneva,sans-serif"><strong><span style="color:#FFFFFF"><span style="font-size:110px"><span style="background-color:#000000"><?php $consultor1=$_POST["f_consultor1"]; echo $_POST['f_consultor1']; ?></span></span></span></strong></span></td>
        </tr>
        <tr>
            <td style="text-align:center"><span style="color:#FF0000"><strong><span style="font-size:100px"><?php $penultimo = $_POST["f_penultimo"]; echo $_POST['f_penultimo']; ?></span></strong></span></td>
            <td><span style="font-family:tahoma,geneva,sans-serif"><strong><span style="color:#FFFFFF"><span style="font-size:110px"><span style="background-color:#000000"><?php $consultor2=$_POST["f_consultor2"]; echo $_POST['f_consultor2']; ?></span></span></span></strong></span></td>
        </tr>
        <tr>
            <td style="text-align:center"><span style="color:#FF0000"><strong><span style="font-size:100px"><?php $antepenultimo=$_POST["f_antepenultimo"]; echo $_POST['f_antepenultimo']?></span></strong></span></td>
            <td><span style="font-family:tahoma,geneva,sans-serif"><strong><span style="color:#FFFFFF"><span style="font-size:110px"><span style="background-color:#000000"><?php $consultor3=$_POST["f_consultor3"]; echo $_POST['f_consultor3']; ?></span></span></span></strong></span></td>
        </tr>
    </tbody>
</table>


<p style="text-align:center"><strong><span style="font-size:80px"><span style="font-family:arial,helvetica,sans-serif"><span style="color:#FFFF00"><span style="background-color:#000000">TOTAL DE PARCELAS</span></span></span></span></strong></p>

<p style="text-align:center"><span style="font-family:arial,helvetica,sans-serif"><span style="font-size:180px"><span style="background-color:rgb(0, 0, 0)"><strong><span style="color:#FFFFFF"> R$<?php $consultor3=$_POST["f_valor"]; echo $_POST['f_valor']; ?></span></strong></span></span></span></p>
    
asked by anonymous 05.12.2018 / 12:10

2 answers

1

Try a connection as follows:

$conn = mysqli_connect('HOST', 'USERNAME', 'PASSWORD', 'NAME_TABLE');

if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

mysqli_set_charset($conn, 'utf8');


$sql = mysqli_query($conn, "SELECT * FROM table ");

 while($row = mysqli_fetch_assoc($sql)) {

 echo $row['n_acordos'];
 }
    
05.12.2018 / 12:25
0
        

FORMAL AGREEMENTS

    
<body>
</br>

    <form name="f_cad" class="form-horizontal" method="POST" action="recebe.php">
     <div class="row">
          <div class="col-md-4 mb-3">
            <label for="firstName">Nº Total de Acordos</label>
            <div class="col-sm-6">
            <input type="number_format" class="form-control" name="f_total" placeholder="Digite Aqui" value="" required />
            <div class="invalid-feedback">
            </div>
          </div>
          </div>
          <div class="col-md-6 mb-3">
            <label for="lastName">Total de Parcelas</label>
            <div class="col-sm-6">
            <input type="number_format" class="form-control" name="f_valor" placeholder="Digite Aqui" value="" required />
            <div class="invalid-feedback">
              </div>
          </div>
        </div>
        </div>
        <div class="row">
          <div class="col-md-4 mb-3">
            <label for="firstName">Nº Último Acordo</label>
            <div class="col-sm-6">
            <input type="number_format" class="form-control" name="f_ultimo" placeholder="Digite Aqui" value="" required />
            <div class="invalid-feedback">
            </div>
          </div>
          </div>
          <div class="col-md-6 mb-3">
            <label for="lastName">Nome do consultor</label>
            <div class="col-sm-6">
            <input type="text" class="form-control" name="f_consultor1" placeholder="Digite Aqui" value="" required />
            <div class="invalid-feedback">
              </div>
          </div>
        </div>
        </div>
          <div class="row">
          <div class="col-md-4 mb-3">
            <label for="firstName">Nº Penúltimo Acordo</label>
            <div class="col-sm-6">
            <input type="number_format" class="form-control" name="f_penultimo" placeholder="Digite Aqui" value="" required />
            <div class="invalid-feedback">
            </div>
          </div>
          </div>
           <div class="col-md-6 mb-3">
            <label for="lastName">Nome do consultor</label>
            <div class="col-sm-6">
            <input type="text" class="form-control" name="f_consultor2" placeholder="Digite Aqui" value="" required />
            <div class="invalid-feedback">
              </div>
          </div>
        </div>
        </div>

            <div class="row">
          <div class="col-md-4 mb-3">
            <label for="firstName">Nº Antepenultimo Acordo</label>
            <div class="col-sm-6">
            <input type="number_format" class="form-control" name="f_antepenultimo" placeholder="Digite Aqui" value="" required />
            <div class="invalid-feedback">
            </div>
          </div>
          </div>
          <div class="col-md-6 mb-3">
            <label for="lastName">Nome do consultor</label>
            <div class="col-sm-6">
            <input type="text" class="form-control" name="f_consultor3" placeholder="Digite Aqui" value="" required />
            <div class="invalid-feedback">
              </div>
          </div>
        </div>
        </div>
        </br>
        <div class="form-group">
        <div class="col-sm-offset-8 col-sm-4">
        <input type="submit" class="btn btn-primary btn-lg btn-block" value="Atualizar">
        </div>
    </div>
    </center>
    </div>

    </form>
    
05.12.2018 / 12:36