About method form :
When sending data from a form in PHP , the usual methods are GET
and POST
. The variables sent with GET
go to the URL of the request, as in the following example:
http://example.com/consulta.php?NumeroCartao=2890127812781233
and should be retrieved in PHP with $_GET['NumeroCartao']
.
Already sent with POST
, go in the body of the request, and do not appear in URL . These must be recovered $_POST['NumeroCartao']
.
For your code, you need to make sure that you are using the POST
method
<form action="consulta.php" method="post">
<label>Numero da Carteira:</label> <span><?php echo $linha['NumeroCartao'];?></span>
<div>
<input class="numerocarteira" id="NumeroCartao" name="NumeroCartao" type="hidden" value="<?php echo $linha['NumeroCartao']; ?>" />
<input id="NumeroCartaoDis" name="NumeroCartaoDis" type="text" disabled="" value="<?php echo $linha['NumeroCartao']; ?>" />
</div>
</form>
Other considerations:
Not directly linked to form, but you can take advantage of and use single quotation marks in this case:
echo 'NUMERO CARTA0 {'.$NumeroCartao.'}';
With double quotation marks, the {
character has a special function in PHP to interpret variables, but rather to avoid ambiguities.
Although PHP allow this format:
<?= $linha['NumeroCartao']; ?>
Give preference to the long version whenever you can:
<?php echo $linha['NumeroCartao']; ?>
So your application will become more portable if you ever go to a server where the <?
short tags are disabled.