Ver Mensaje Individual
  #9 (permalink)  
Antiguo 30/11/2013, 19:37
Avatar de xSkArx
xSkArx
 
Fecha de Ingreso: marzo-2008
Ubicación: Chile
Mensajes: 945
Antigüedad: 16 años, 1 mes
Puntos: 96
Respuesta: Almacenar variables en array desde formulario

Prueba esto
Código PHP:
Ver original
  1. <?php
  2. ?>
  3. <!DOCTYPE html>
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  7. <title></title>
  8. </head>
  9. <body>
  10. <center>
  11. <?php
  12. if(isset($_POST['producto']) && isset($_POST['referencia'])) {
  13. $_SESSION['array'][]['producto']=$_POST['producto'];
  14. $_SESSION['array'][]['referencia']=$_POST['referencia];
  15. }
  16. foreach($_SESSION['array'] as $array) {
  17. foreach($array as $clave=>$valor){
  18. echo $clave . " " . $valor['producto'];
  19. }
  20. }
  21.  
  22. ?>
  23. <form name="formulario" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  24. Producto:<input type="text" name="producto"/>
  25. Referencia:<input type="text" name="referencia"/><br/>
  26. <input type="submit" value="Insertar"/>
  27. </form>
  28. </center>
  29. </body>
  30. </html>
__________________
Busca, lee y practica todo lo que puedas.
Usa siempre el buscador antes de postear.
Si posteas código, utiliza el HIGHLIGHT correcto.