Ver Mensaje Individual
  #7 (permalink)  
Antiguo 01/03/2016, 06:47
xerifandtomas
 
Fecha de Ingreso: octubre-2010
Ubicación: España
Mensajes: 1.007
Antigüedad: 13 años, 6 meses
Puntos: 123
Respuesta: Pasar por POST con un FOREACH

Antes de continuar, estaría bien que trates de explicar que es lo que tratas/quieres enviar desde el formulario.

Si solo necesitas pasar pasar un valor y no un conjunto de valores, no hay ninguna necesidad de utilizar un array y por tanto tampoco de usar foreach.

Ejemplos:
Formulario 1 dato por variable, múltiples variables
Código HTML:
Ver original
  1. <form ... >
  2. <input type="text" name="variable1" />
  3. <input type="text" name="variable2" />
  4. <input type="text" name="variable3" />
  5. Otros input...
El formulario generará 3 variables ($_POST['variable1'],$_POST['variable2'],$_POST['variable3']) y cada una contendrá el valor introducido como un String.

Formulario array de datos
Código HTML:
Ver original
  1. <form ... >
  2. <input type="text" name="variable[]" />
  3. <input type="text" name="variable[]" />
  4. <input type="text" name="variable[]" />
  5. Otros input...
El formulario generará un array ( $_POST['variable'] ) de 3 elementos.