0
Good afternoon!
A PHP page contains two forms form
, each with a submit
. How to obtain data from form
1, for example, after pressing the Submit through the POST? Usually when there was only one form it would pick up the data directly through the code below: (CNPJ being the id of a input
form):
table {
float: left;
}
<form id="localizacao" name="localizacao" method="post" action="rastreamento.php" onsubmit=" return false;">
<table width="50%" border="1">
<tr>
<div align="center"><img src=img/logo.jpg></div>
</tr>
<tr>
<th colspan="5" align="center" valign="top">
<h2>Pesquisa</h2>
</th>
</tr>
<tr>
<td width="156">Selecione o STATUS:</td>
<td>
<select name="status" id="status">
<option value="0">Recebido</option>
<option value="1">Em trânsito</option>
<option value="2">Encerrado</option>
</select>
</td>
</tr>
<tr>
<td>CNPJ:</td>
<td width="835"><input name="CNPJ" type="text" id="CNPJ" size="20" maxlength="14" />
<span class="style1">*</span> <span class="style3">somente números</span></td>
</tr>
<tr>
<td>
VIAGEM:
</td>
<td width="835"><input name="VIAGEM" type="text" id="VIAGEM" size="20" maxlength="14" />
</td>
</tr>
<tr>
<td colspan="2">
<p>
<input name="pesquisar" type="submit" id="pesquisar" value="Pesquisar" />
<br />
<input name="limpar" type="reset" id="limpar" value="Limpar!" />
<br />
</p>
</td>
</tr>
</table>
</form>
<form id="alteracoes" name="alteracoes" method="post" action="rastreamento.php" onsubmit="return validaCampoAltera(); return false;">
<table width="50%" border="1">
<tr>
<th colspan="5" align="center" valign="top">
<h2>Modifica</h2>
</th>
</tr>
<tr>
<td width="50">VIAGEM:</td>
<td width="835"><input name="VIAGEM" type="text" id="VIAGEM" size="20" maxlength="14" />
</tr>
<tr>
<td width="50">NOVO STATUS:</td>
<td width="835"><input name="NVSTATUS" type="text" id="NVSTATUS" size="1" maxlength="1" />
</tr>
<tr>
<td width="50">EMBARCACAO:</td>
<td width="835"><input name="EMBARC" type="text" id="EMBARC" size="20" maxlength="10" />
</tr>
<tr>
<td width="50">DATA SAIDA:</td>
<td width="835"><input name="DATSAI" type="text" id="DATSAI" size="20" maxlength="10" />
</tr>
<tr>
<td width="50">HORA SAIDA:</td>
<td width="835"><input name="HORSAI" type="text" id="HORSAI" size="20" maxlength="10" />
</tr>
<tr>
<td width="50">DATA CHEGADA:</td>
<td width="835"><input name="DATCH" type="text" id="DATCH" size="20" maxlength="10" />
</tr>
<tr>
<td width="50">HORA CHEGADA:</td>
<td width="835"><input name="HORCHE" type="text" id="HORCHE" size="20" maxlength="10" />
</tr>
<tr>
<td colspan="2">
<p>
<input name="atualizar" type="submit" id="atualizar" value="ATUALIZAR" />
<br />
</p>
</td>
</tr>
</table>
</form>
if (isset($_POST["CNPJ"])){
$CNPJ = $_POST ["CNPJ"];
}
Please include more information and detail better
– user38174
If they are two forms, they will be submitted individually: either submit the first, or the second. Submit one does not send the data of the other.
– Woss
@Andersoncarloswoss, how to get him to take the data from
formulario1
, for example? It would be something like$CNPJ = $_POST ["formulario1.CNPJ"]
?– Marvin
What is your HTML code like? What form are you submitting?
– Woss
@Andersoncarloswoss, question edited with HTML code.
– Marvin
@Marvin you will only have access to the data of the submitted form, if you do not submit the first you will not have access to his data.
– Jhonny Freire
You could only use a button to submit both forms at the same time, otherwise I think there is no form.
– White