-2
<?php
require_once('cabecalho.php');
require_once('conn.php');
?>
<?php
$nome = $_REQUEST["nome"];
$preco = $_REQUEST["preco"];
$query = "insert into produtos (nome, preco) values ('{$nome}', '{$preco}')";
if(mysqli_query($conn, $query)){ ?>
<p class="alert-success">Produto <?= $nome ?> <?= $preco ?> adicionado.</p>
<?php } else { ?>
<p class="alert-danger">Produto <?= $nome; ?> não foi adicionado.</p>
<?php } ?>
</header>
</section>
<?php include('rodape.php'); ?>
Try to use the
mysqli_error
to display an error message that is useful to you in development.– Woss
"I can’t get into the database" is somewhat vague/generic, since this may have many different causes. Can be values are of a different type than defined in the bank, or outside the allowed values (exceeded maximum size, is
null
when the column does not allow, etc etc etc), or anything else. Please click on the [Edit] link just below the question tags and add more information (table structure, data to be entered, error message, etc.), because the way it is, we have no way to guess. Try to make the question contain a [mcve]– hkotsubo