I am having trouble inserting data into a table with php

1

My form looks like this:

<form name="pedidooo" action="cadastrandoPedido.php" method="post" >

    <?php
    include './conex.php';

    $query = ("SELECT * FROM conta");
    $result = $mysqli->query($query);
    echo '<gg>Numero da Conta:<gg>';
    echo "<select name='conta'>";
    while ($fetch = $result->fetch_assoc()) {
        $value = $fetch['NR_CONTA'];
        echo "<option>";
        echo ($value);
        echo "</option>";
    }
    echo "</select>";
    echo"<br>";
    echo"<br>";

    $query = ("SELECT * from itemcardapio");
    $result = $mysqli->query($query);
    echo '<gg>Numero do Item do cardápio:</gg>';
    echo "<select name='item'>";
    while ($fetch = $result->fetch_assoc()) {
        $valu = $fetch['NR_ITEM'];
                        echo "<option>";
        echo ($valu);

        echo "</option>";
    }
    echo "</select>";
    echo"<br>";
    echo"<br>";

    echo "</select>";
    echo"<br>";

    $query = ("SELECT * from itemcardapio");
    $result = $mysqli->query($query);
    echo '<gg>Numero do Item do cardápio:</gg>';
    echo "<select name='preco'>";
    while ($fetch = $result->fetch_assoc()) {
        $value = $fetch['PRECO'];
         echo "<option>";
        echo ($value);

        echo "</option>";
    }
    echo "</select>";
    echo"<br>";
    echo"<br>";
    ?>
    Quantidade: <input type="number" name="quantidade" value="1" /><br><
    <button type="submit">Fazer Pedido</button> <br></center>

</form>

The action page for my form is as follows:

<?php
include './conex.php';

$valor=0;
$item=$_POST['item'];
$conta=$_POST['conta'];
$quant=$_POST['quantidade'];
$preco=$_POST['preco'];
$valor=$valor+($preco*$quant);

$qr = $mysqli->query( "INSERT INTO pedido (NR_CONTA, NR_ITEM, QUANTIDADE, PRECO_UNITARIO) values( '$conta', '$item', '$quant', '$valor)");

echo'<link href="style.css" rel="stylesheet" type="text/css"/>';
echo "<gg>Pedido cadastrado com sucesso!<gg>";
echo "<gg>Total: !</gg>";
echo "<gg>$valor</gg>";

?>

Theproblemisthatitdoesnotenterthebank...

conex.php<?php$servidor="localhost";
$usuario="root";
$senha="";
$bd="obaratao";

$mysqli=new mysqli($servidor, $usuario, $senha, $bd);

if (mysqli_connect_errno()){ die ('Algum probleminha....'.mysqli_connect_errno());
 exit();
}

?>
    
asked by anonymous 25.11.2017 / 11:51

0 answers