The goal is to send 10 values using the POST method through the form, and insert them into a vector, which will be printed later.
Anyone can help me thank you right away.
The goal is to send 10 values using the POST method through the form, and insert them into a vector, which will be printed later.
Anyone can help me thank you right away.
According to this author's comment
I have two input fields in the form, one type number and the other submit, when I submit I want the number entered in the number field to go to an array position, each new number inserted in a new position, and then with the vector already complete with the 10 numbers, print it out. "One way to get this result is to use sessions.
PHP
session_start();
if(!empty($_POST['num']) && isset($_POST['num']) ){
//contagem do numero de vezes que o formulário foi submetido
$_SESSION['dez']=$_SESSION['dez']+1;
$numPost = $_POST['num'];
if ($_SESSION['num']==""){
$_SESSION['num'] = $numPost;
}else{
$_SESSION['num'] = $_SESSION['num'].",".$numPost;
}
if ($_SESSION['dez']==10){
$meuarray = explode(',', $_SESSION['num']);
print_r($meuarray);
session_destroy();
}
}
HTML
<form action="" method="post">
<label><input type="number" name="num" value="" required><br>
<input type="submit">
</form>