0
How can I send data from the first form to the second and then send to mysql ?
I tried everything, and when I send it to the database, only the data from the second comes in. I will put down my forms and mysql .
I am grateful in advance .
form 1
<main>
<div class="pedidos">
<form method="post" action="fazer2.php">
<table >
<tr>
<td colspan="4" width="100">
<span>Mesa</span>
<input type="text" id="numero_mesa" name="numero_mesa">
<label>
<span>Comanda:</span>
<?php
$row = mysqli_fetch_array($resultado_id);
echo '<span>'.$row['ultimo'].'</span>';
?>
</label>
<br>
<br>
</td>
</tr>
<tr>
<td width="280" bgcolor="#00BFFF">Refeição</td>
<td width="70" bgcolor="#00BFFF">Quantidade</td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_refeicao[]" value="Costela de Tambaqui sem Espinha">Costela de Tambaqui sem Espinha</td>
<td width="20"><input type="text" name="num_refeicao[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_refeicao[]" value="Lombo de Tambaqui Frito sem Espinha">Lombo de Tambaqui Frito sem Espinha</td>
<td width="20"><input type="text" name="num_refeicao[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_refeicao[]" value="Caldeirada de Tambaqui sem Espinha">Caldeirada de Tambaqui sem Espinha</td>
<td width="20"><input type="text" name="num_refeicao[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_refeicao[]" value="Caldeirada de Tucunaré">Caldeirada de Tucunaré</td>
<td width="20"><input type="text" name="num_refeicao[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_refeicao[]" value="Peixe no Tucupi com Camarão">Peixe no Tucupi com Camarão</td>
<td width="20"><input type="text" name="num_refeicao[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_refeicao[]" value="Escabeche de Pirarucu">Escabeche de Pirarucu</td>
<td width="20"><input type="text" name="num_refeicao[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_refeicao[]" value="Escabeche de Tambaqui">Escabeche de Tambaqui</td>
<td width="20"><input type="text" name="num_refeicao[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_refeicao[]" value="Escabeche de Tucunaré">Escabeche de Tucunaré</td>
<td width="20"><input type="text" name="num_refeicao[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_refeicao[]" value="Tucunaré Frito">Tucunaré Frito</td>
<td width="20"><input type="text" name="num_refeicao[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_refeicao[]" value="Sardinha Frita">Sardinha Frita</td>
<td width="20"><input type="text" name="num_refeicao[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_refeicao[]" value="Jaraqui Frito">Jaraqui Frito</td>
<td width="20"><input type="text" name="num_refeicao[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_refeicao[]" value="Pacu Frito">Pacu Frito</td>
<td width="20"><input type="text" name="num_refeicao[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_refeicao[]" value="Filé de Pirarucu Frito">Filé de Pirarucu Frito</td>
<td width="20"><input type="text" name="num_refeicao[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_refeicao[]" value="Filé de Pirarucu a Milanesa">Filé de Pirarucu a Milanesa</td>
<td width="20"><input type="text" name="num_refeicao[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_refeicao[]" value="Guisado de Pirarucu">Guisado de Pirarucu</td>
<td width="20"><input type="text" name="num_refeicao[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_refeicao[]" value="Caldeirada No Tucupi com Camarao">Caldeirada No Tucupi com Camarão</td>
<td width="20"><input type="text" name="num_refeicao[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_refeicao[]" value="Caldinho de Tambaqui">Caldinho de Tambaqui</td>
<td width="20"><input type="text" name="num_refeicao[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_refeicao[]" value="Feijão">Feijão</td>
<td width="20"><input type="text" name="num_refeicao[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_refeicao[]" value="Arroz">Arroz</td>
<td width="20"><input type="text" name="num_refeicao[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_refeicao[]" value="Farofa">Farofa</td>
<td width="20"><input type="text" name="num_refeicao[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_refeicao[]" value="Vinagre">Vinagre</td>
<td width="20"><input type="text" name="num_refeicao[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_refeicao[]" value="Isca de Pirarucu">Isca de Pirarucu</td>
<td width="20"><input type="text" name="num_refeicao[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_refeicao[]" value="Bolinho">Bolinho</td>
<td width="20"><input type="text" name="num_refeicao[]" size="7"></td>
</table>
<br>
<input class="btn" type="submit" value="Proximo" name="Proximo">
</form>
form 2
<?php
session_start();
error_reporting(-1);
ini_set('display_errors', 'On');
//Criar a conexao
$link = new mysqli ("localhost", "root", "", "peixaria");
if($link->connect_errno){
echo"Nossas falhas local experiência ..";
exit();
}
$sql= "SELECT MAX(m.id_pedido)+1 as ultimo FROM mpedido as m WHERE id_pedido ORDER BY m.id_pedido DESC LIMIT 1";
$resultado_id= mysqli_query($link,$sql);
$mesa = isset($_POST['numero_mesa']) ? $_POST[''] : '';
$_SESSION['numero_mesa'] = $mesa;
$pedido = isset($_POST['pedido_refeicao']) ? $_POST['pedido_refeicao'] : '';
$_SESSION['email'] = $pedido;
$bebida = isset($_POST['num_refeicao']) ? $_POST['num_refeicao'] : '';
$_SESSION['num_refeicao'] = $bebida;
?>
<main>
<div class="pedidos">
<form method="post" action="relatorio.php">
<table >
<tr>
<tr>
<td colspan="4" width="100">
<span>Mesa</span>
<input type="text" id="numero_mesa" name="numero_mesa">
<label>
<span>Comanda:</span>
<?php
$row = mysqli_fetch_array($resultado_id);
echo '<span>'.$row['ultimo'].'</span>';
?>
</label>
<br>
<br>
</td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_bebida[]" value="Fanta Laranja 1l">Fanta Laranja 1l</td>
<td width="20"><input type="text" name="num_bebida[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_bebida[]" value="Fanta Laranja 2l">Fanta Laranja 2l</td>
<td width="20"><input type="text" name="num_bebida[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_bebida[]" value="Cola Cola 1l">Cola Cola 1l</td>
<td width="20"><input type="text" name="num_bebida[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_bebida[]" value="Cola Cola 2l">Cola Cola 2l</td>
<td width="20"><input type="text" name="num_bebida[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_bebida[]" value="Bare 2l">Bare 2l</td>
<td width="20"><input type="text" name="num_bebida[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_bebida[]" value="Fanta Uva">Fanta Uva</td>
<td width="00"><input type="text" name="num_bebida[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_bebida[]" value="Fanta Laranja">Fanta Laranja</td>
<td width="00"><input type="text" name="num_bebida[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_bebida[]" value="Sprit">Sprit</td>
<td width="00"><input type="text" name="num_bebida[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_bebida[]" value="Cola Cola">Cola Cola</td>
<td width="20"><input type="text" name="num_bebida[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_bebida[]" value="Cola Cola zero">Cola Cola zero</td>
<td width="20"><input type="text" name="num_bebida[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_bebida[]" value="Guaraná Antarctica">Guaraná Antarctica</td>
<td width="20"><input type="text" name="num_bebida[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_bebida[]" value="Guaraná Baré">Guaraná Baré</td>
<td width="20"><input type="text" name="num_bebida[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_bebida[]" value="Suco Manga">Suco Manga</td>
<td width="20"><input type="text" name="num_bebida[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_bebida[]" value="Suco Pessego">Suco Pessego</td>
<td width="00"><input type="text" name="num_bebida[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_bebida[]" value="Suco Goiaba">Suco Goiaba</td>
<td width="00"><input type="text" name="num_bebida[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_bebida[]" value="Suco Uva">Suco Uva</td>
<td width="00"><input type="text" name="num_bebida[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_bebida[]" value="Suco Maracujá">Suco Maracujá</td>
<td width="00"><input type="text" name="num_bebida[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_bebida[]" value="Suco Laranja">Suco Laranja</td>
<td width="20"><input type="text" name="num_bebida[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_bebida[]" value="Suco Caju">Suco Caju</td>
<td width="20"><input type="text" name="num_bebida[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_bebida[]" value="Agua Mineral">Agua Mineral</td>
<td width="20"><input type="text" name="num_bebida[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_bebida[]" value="Agua com Gas">Agua com Gas</td>
<td width="20"><input type="text" name="num_bebida[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_bebida[]" value="Cerveja em Lata">Cerveja em Lata</td>
<td width="20"><input type="text" name="num_bebida[]" size="7"></td>
</tr>
<tr>
<td width="280"><input type="checkbox" name="pedido_bebida[]" value="Limonada Natural">Limonada Natural</td>
<td width="20"><input type="text" name="num_bebida[]" size="7"></td>
</tr>
<tr>
</table>
<br>
<button class="btn" type="submit">Fazer Pedido</button>
</form>
</div>
</main>
and mysql
<?php
error_reporting(-1);
ini_set('display_errors', 'On');
//Criar a conexao
$link = new mysqli ("localhost", "root", "", "peixaria");
if($link->connect_errno){
echo"Nossas falhas local experiência ..";
exit();
}
if($_POST)
{
$numero_mesa = $_POST['numero_mesa'];
$pedido_refeicao = implode(', ', $_POST['pedido_refeicao']);
$num_refeicao = implode(', ', $_POST['num_refeicao']);
$pedido_bebida = implode(', ', $_POST['pedido_bebida']);
$num_bebida = implode(', ', $_POST['num_bebida']);
$sql="INSERT INTO mpedido(numero_mesa,pedido_refeicao,num_refeicao,pedido_bebida,num_bebida) VALUES('$numero_mesa','$pedido_refeicao','$num_refeicao','$pedido_bebida','$num_bebida')";
$resultado_pedido = mysqli_query($link,$sql);
}
$sql= "SELECT id_pedido,numero_mesa,pedido_refeicao,num_refeicao,pedido_bebida,num_bebida,data FROM mpedido ORDER BY id_pedido DESC LIMIT 1";
$consulta = mysqli_query($link,$sql);
?>
Poxa Allan... although it is difficult for me(pq Naum am expert) I will try to help...
– MagicHat
Thank you very much @Magichat
– allan araujo
Let’s try to divide the problem into parts.... What are the forms you want to work on in this action ? Note that I see 2 Forms but none have a name, they have 2 different actions 1-doir2.php and 2.php report, what exactly do you want to do ? Here I’ll come out but I’ll be back...
– MagicHat
they are Do.php and do 2.php and in the report send to mysql and list to show on screen .
– allan araujo
Right, and where is Fazer.php ?
– MagicHat
@Magichat is the first code . the second is to make 2.php and the third is the report.php
– allan araujo
What data do you want to send from 1st to 2nd ? and where do you want to receive this data in 2nd form ?... Or what you want is to fill the first press next, fill the 2nd and send to the bank ?
– MagicHat
well I wish to send the data from form one to 2 and from two to mysql , and I will select several checkbox and input number
– allan araujo
So what I’m not getting is if you want to send the form 1 data to form2, how do you imagine that form2 will receive this data ? form2 will display the Form1 data? I’m not understanding the relation between Form1 and form2...
– MagicHat