hola a todos me podrian ayudar por favor, tengo un listado de productos en php, que estoy tratando de enviar por mail, donde el cliente rellena un formalario con sus datos personales por ejemplo nombre, apellido, direccion, etc y selecciona el o los productos que desea con un ckeckbox. Cuando le doy enviar los datos personales me llegan correctamente pero no asi los productos que selecciono en el ckeckbox solo me llega on, aca les dejo mi codigo, no se que estoy haciendo mal.
desde ya muchas gracias a todos por la ayuda.
este es mi codigo.
lista_prod.php
=============
<?php
include("conector.php");
$list_prod = "select * from producto";
$resul_list_prod = mysql_query ($list_prod, $conexion) or die (mysql_error());
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
</head>
<body>
<form action="enviar.php" method="post">
<center>PRODUCTOS</center>
<table border="1" align="center">
<tr>
<td>Producto</td><td>Precio</td>
</tr>
<?php while($row = mysql_fetch_assoc($resul_list_prod)){?>
<tr>
<td><?php echo $row['producto'];?></td>
<td><?php echo $row['precio'];?></td>
<td><input type="checkbox" name="seleccion[]"/></td>
</tr>
<?php
}//fin del while
?>
<tr>
<td>Nombre:</td>
<td><input type="text" name="nombre"></td>
</tr>
<tr>
<td>Apellido:</td>
<td><input type="text" name="apellido"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="comprar" name="comprar" /></td>
</tr>
</table>
</form>
<?php mysql_free_result($resul_list_prod);?>
</body>
</html>
enviar.php
=========
<?php
foreach($_POST['seleccion'] as $clave => $valor){
//$seleccion = $_POST['seleccion'];
}
$nombre = $_POST ['nombre'];
$apellido = $_POST ['apellido'];
$header = 'From: ' . $mail . " \r\n";
$header .= "X-Mailer: PHP/" . phpversion() . " \r\n";
$header .= "Mime-Version: 1.0 \r\n";
$header .= "Content-Type: text/plain";
$mensaje = "Este mensaje fue enviado por " . $nombre . " y sus productos seleccionados son " . $valor . "\r\n";
$mensaje .= "Su e-mail es: " . $mail . " \r\n";
$mensaje .= "Enviado el " . date('d/m/Y', time());
$para = 'micorreo@hotmail.com'; // aqui iria mi correo
$asunto = 'prueba quiniela';
echo "$mensaje";
mail($para, $asunto, $header, $mensaje);
echo 'Muchas Gracias';
?>