3
The code is like this:
<form method="post" action="pagina.php"/>
<?php
$c= 1;
$neg = 0;
while($c <=3){
echo "Digite um numero: <input type='number' name='$num' min='1'/>";
if($num < $neg){
$total++;
}
$c++;
}
?>
<input type='submit' value='Resultado'/>
I’m not sure how to do what the user typed, it becomes a variable so I can use the control structure on it. I tried putting a direct variable in the name ($num), but it doesn’t seem to work or it doesn’t work. Or this kind of thing is for Javascript ?
I would suggest reading the introductory pages of the PHP manual. Your code makes no sense. PHP is not a language that naturally interacts with user when used via HTML and browser. PHP only assembles static things. The client receives the content, and if he wants to interact, he has to call a new PHP (or the same, but in a new execution). Start here, with attention to detail: http://us3.php.net/manual/en/getting-started.php - If you are easy with English, better still, the documentation in Portuguese is of less quality (but for the basics it is already good)
– Bacco
If you want to know what is written in the form, just use javascript, $("form"). val(); If you want to take php, just send the form via ajax or to a page and turn into variable, using POST or GET methods
– Sampaio Leal