Ver Mensaje Individual
  #3 (permalink)  
Antiguo 08/02/2009, 05:21
afrika91
 
Fecha de Ingreso: diciembre-2008
Mensajes: 14
Antigüedad: 15 años, 4 meses
Puntos: 1
Respuesta: Formulario dinámico con uso de matriz

formulario.php

............

<?php do { ?>
<tr>
<td><input name="CodProd[]" type="text" id="CodProd" value="<?php echo $row_rspedidosd['CodProd']; ?>" /></td>
<td><input name="NombreProducto[]" type="text" id="NombreProducto" value="<?php echo $row_rspedidosd['NombreProducto']; ?>" size="80" maxlength="80" /></td>
<td><input name="PrecioUnidad[]" type="text" id="PrecioUnidad" value="<?php echo $row_rspedidosd['PrecioUnidad']; ?>" size="10" /></td>
<td><input name="cantidad[]" type="text" id="cantidad" value="<?php echo $row_rspedidosd['Cantidad']; ?>" size="10" /></td>
<td><input name="subtotal[]" type="text" id="subtotal" value="<?php echo $row_rspedidosd['Subtotal']; ?>" size="10" /></td>
<td><input name="Descuento[]" type="text" id="Descuento" value="<?php echo $row_rspedidosd['Descuento']; ?>" size="10" /></td>
</tr>
<?php } while ($row_rspedidosd = mysql_fetch_assoc($rspedidosd)); ?>

<?php
if($Submit){
for($i=0;$i<$totalRows_rspedidosd;$i++)
?>

..........



Y aca la parte del envio de los datos

..........

enviar.php

<?php
$msg = "Datos del Pedido Realizado\n\n";


$field_name = array_keys($_POST); // guardamos todos los nombres de los "fields" existentes en el formulario
$value_name = array_values($_POST);// guardamos todos los valores en sus respectivas variables
for ($i=0;$i<count($field_name);$i++)
{
$msg .= "".$field_name[$i].": ".$value_name[$i]."\n\n"; // $msg reune el nombre de la variable y su valor
}
$recipient = "xxxxxxx"; // el mail deseado
$recipient2 = "xxxxxxx";
$subject = "Datos del Pedido Realizado"; // el titulo del mail
$mailheaders = "From: Dominio <http : // xxxxxx . xxx> \n"; // quien lo manda y el dominio
$mailheaders .= "Reply-To: ".$ mail."\n\n"; // responder a: Importante! si quieres que el replay:to funcione tienes
//que tener en el formulario un field que tiene como nombre "mail ".
mail($recipient, $subject, $msg, $mailheaders);// mandamos el mail con los todos los datos
mail ($recipient2, $subject, $msg, $mailheaders);
header ('location:xxxxx.php '); // y vamos a la pagina en donde nos dan las gracias por haber llenado en formulario
?>

Muchas Gracias de antemano.