-1
I want it to show me the amount the customer enters in the quantity field.
HTML code:
<style>
header form input { display: block; margin-top:10px; }
</style>
<header>
<form action="etiqueta.php" method="POST">
<input type="text" placeholder="Nome do Produto" name="nomeproduto">
<input type="text" placeholder="Outra Informação" name="outrainformacao">
<input type="text" placeholder="Marca" name="marca">
<input type="text" placeholder="Quantidade" name="quantidade"><BR>
<button>Carregar Etiquetas</button>
</form>
</header>
This is the tag code.php
<?php
$nomeproduto = $_POST['nomeproduto'];
$outrainformacao = $_POST['outrainformacao'];
$marca = $_POST['marca'];
$quantidade = $_POST['quantidade'];
$quantidademaxima = 4;
while($quantidade >= $quantidademaxima) {
echo "$nomeproduto e $outrainformacao e $marca e $quantidade";
$quantidade++;
}
I want the amount that the client typed in the form field to be displayed in the tag code.php . Can you please help me.
You’re already doing it. What’s the difficulty?
– Woss
When I enter the value, it loops
– EuSou Noob
If the value is greater than 4 you will loop as long as it is greater than 4, incrementing with each iteration. That is, it will always be greater than 4 and the loop never ends.
– Woss
@Andersoncarloswoss. Yes, I understood. However, it has some possibility to display only what the user type ?
– EuSou Noob
@Andersoncarloswoss When I put the value == It works, however, above 4 does not work.
– EuSou Noob
Because it goes into infinite loop... you just review your logic and define exactly what you need to do.
– Woss
Just a hunch, it’s not mandatory or definitive, but where
$quantidade++;
do$quantidade--;
.– Augusto Vasques
@Augustovasques Thank you young man, it worked.
– EuSou Noob
PS: Maybe for an exercise it is enough, but if the code is commercial I think it is not the best solution. Personally I think the way would be to inform the user that the value extrapolated the stock and return the focus on the front end to the input that selects the quantity with the value at the maximum available. I suggested the
$quantidade--;
only to direct thought.– Augusto Vasques