Good afternoon!
A page in PHP contains two form
forms, each with a submit
. How to get data from form
1, for example, after pressing submit through POST? Normally when there was only one form it would get the data directly through the code below: (where CNPJ was the id of a input
of the 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"];
}