1
I have this code and form and when pressing register to insert in the table (which you already insert correctly) I wanted you to update the page automatically to update a query that I show before to the user.
<?php
$servername = "xxx.xxx.x.xx";
$username = "xxxxx";
$password = "xxxxxxxx";
$dbname = "xxxxxxx"
$conn = new mysqli($servername, $username, $password, $dbname);
$conn->set_charset('utf8');
$pedido = $_POST['NumPedido'];
$data = $_POST['DataSaida'];
$funcionario = $_POST['Funcionario'];
$funcao = $_POST['Funcao'];
$IdTipoLuva = $_POST['IdTipoLuva'];
$tipoluva = $_POST['TipoLuva'];
$IdTamanho = $_POST['IdTamanho'];
$tamanho = $_POST['Tamanho'];
$quantidade = $_POST['Quantidade'];
$produto = $_POST['Produto'];
$qtd = $_POST['QtaHigiene'];
$observacoes = $_POST['Observacoes'];
$estado = $_POST['Estado'];
$sql = "INSERT INTO RegSaidaLuvas (`NumPedido`,`DataSaida`,`Funcionario`,`Funcao`,`IdTipoLuva`,`TipoLuva`,`IdTamanho`,`Tamanho`,`Quantidade`,`Observacoes`)
VALUES ('$pedido','$data','$funcionario','$funcao','$IdTipoLuva','$tipoluva','$IdTamanho','$tamanho','$quantidade','$observacoes')";
if ($conn->query($sql) === TRUE);
<form name="form" method="POST" onsubmit="return form_validation()" >
<h1><center><strong>Atribuição de Luvas</strong></center></h1></br>
<p><h5><strong>Número da Requisição</strong></h5> <input type="text" required="" id="NumPedido" name="NumPedido" /><br/></p>
<br/>
<label for=""><h5><strong>Nome Colaborador</strong></h5></label>
<select name="Colaborador">
<option value="0">Selecione Colaborador</option>
<?php
$servername = "xxx.xxx.x.xx";
$username = "xxxxx";
$password = "xxxxxxxx";
$dbname = "xxxxxxx";
$conn = new mysqli($servername, $username, $password, $dbname);
$conn->set_charset('utf8');
$sql = "SELECT * FROM InfoLuvas WHERE Ativo = 1 ORDER BY Funcionario ASC";
$qr = mysqli_query($conn, $sql);
while($ln = mysqli_fetch_assoc($qr)){
echo '<option value="'.$ln['Id'].'">'.$ln['Funcionario'].'</option>';
}
?>
</select>
<br/>
<p><h5><strong>Data de Atribuição</strong></h5> <input type="date" required="" id="DataAtribuicao" name="DataAtribuicao" value="<?php echo date("Y-m-d");?>"/><br/></p>
<br/>
<p><h5><strong>Observações</strong></h5></br>
<textarea type="text" id="Observacoes" name="Observacoes" rows="2" cols="90"></textarea><br/></p>
<br/>
<p><h5><strong>Estado</strong></h5>
<p> <input type="radio" name="Estado" value="Entregue" required>Entregue
<p><input type="submit" value="Registar"/>
</form>
INSERT is done after the information you want to show?
– Sam
Yes, the query is right at the beginning of the page and only then comes the form
– user87525
By the way, I don’t think it’s good practice to load the 2x page just to show up-to-date information, when you can do it once.
– Sam
Thanks for the tip, it worked
– user87525