I have a question with PHP
, I make a form with only input
, and with 2 buttons, one to save and another to collect.
The idea is that when you click on the save button, it will be stored in $_SESSION
, as many variables as you type in input
, but it only saves the last written variable.
I put some of the code.
index.php
<body>
<form action="guardar.php" method="post">
<br/><br/>
<h1>Escriba una palabra o un numero</h1><br/>
<input type="text" name="datoparametro" VALUE="" id="datoparametro"><br/><br/>
<input type="submit" name="ok" VALUE="guardar"><br/>
</form>
<input type="submit" value="recojer" onclick="location='recojer.php'"/> <br/>
<input type="submit" value="borrar" onclick="location='borrar.php'"/>
</body>
save.php
<?php
session_start();
$midato=$_POST["datoparametro"];
$_SESSION["dato"]=$midato;
if(isset($_SESSION["dato"])){
$midato=$_SESSION["dato"]+ 1;
}
else{
$midato=array();
$midato[]=$_POST["datoparametro"];
$_SESSION["dato"]=$midato
}
?>