Ver Mensaje Individual
  #10 (permalink)  
Antiguo 15/01/2010, 18:08
Avatar de masterojitos
masterojitos
 
Fecha de Ingreso: julio-2008
Ubicación: Lima Callao Chucuito
Mensajes: 1.931
Antigüedad: 15 años, 9 meses
Puntos: 105
Respuesta: Envio de mail

ya te entendi...... tu lo que deseas es que la cantidad vaya ligada al producto en cada while...... ps lo que pasa que has elaborado mal el formulario....... y el envio de correo, ya que el orden es: email(destinatario, asunto, mensaje, cabezeras).

lista_prod.php
============
Código PHP:
Ver original
  1. <?php
  2. include("conector.php");
  3. $list_prod = "select * from producto";
  4. $resul_list_prod = mysql_query ($list_prod, $conexion) or die (mysql_error());
  5. ?>
  6. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  7. <html xmlns="http://www.w3.org/1999/xhtml">
  8. <head>
  9. <meta http-equiv="Content-Type" content="text/html; charset=ansi"/>
  10. <title>Menu del dia</title>
  11. <style type="text/css">
  12. form.elegante input {
  13. padding: .2em;
  14. }
  15. input:focus {
  16. border: 2px solid #000;
  17. background:#F0F0F0;
  18. }
  19. label {
  20. display: block;
  21. margin: .5em 0 0 0;
  22. }
  23. .btn {
  24. margin: 0em 0;
  25.  
  26. }
  27. div {
  28. margin: .4em 0;
  29. }
  30. div label {
  31. width: 25%;
  32. float: left;
  33. }
  34. -->
  35. </style>
  36. </head>
  37. <body>
  38. <div class="entry">
  39. <center><font color="#000000">MENU DEL DIA</font></center>
  40. <center><font color="#000000">Por favor rellene el formulario</font></center>
  41. <br />
  42. <form action="enviar.php" method="post">
  43. <table border="0" align="center" cellpadding="3" cellspacing="0" width="400" bordercolor="#C0C0C0">
  44. <tr>
  45. <td>Nombre:</td>
  46. <td><input type="text" name="nombre"></td>
  47. </tr>
  48. <tr>
  49. <td>Apellido:</td>
  50. <td><input type="text" name="apellido"></td>
  51. </tr>
  52. <tr>
  53. <td>Empresa</td>
  54. <td><input type="text" name="empresa"></td>
  55. </tr>
  56. <tr>
  57. <td>Direccion:</td>
  58. <td><input type="text" name="direccion"></td>
  59. </tr>
  60. <tr>
  61. <td>Telefono:</td>
  62. <td><input type="text" name="telefono"></td>
  63. </tr>
  64. <tr>
  65. <td>Mail:</td>
  66. <td><input type="text" name="email"></td>
  67. </tr>
  68. </table>
  69. <center><font color="#000000">Por favor seleccione sus productos</font></center>
  70. <br />
  71. <table border="1" align="center" cellpadding="3" cellspacing="0" width="400" bordercolor="#C0C0C0">
  72. <tr align="center" bgcolor="#FFBF00">
  73. <td><font color="#000000">Producto</font></td><td><font color="#000000">Precio</font></td><td><font color="#000000">cantidad</font></td><td></td>
  74. </tr>
  75. <?php
  76. $contador = 0;
  77. while($row = mysql_fetch_assoc($resul_list_prod)){
  78. ?>
  79. <tr>
  80. <td><?php echo $row['producto'];?></td>
  81. <td><?php echo $row['precio'];?></td>
  82. <td align="center">
  83. <select name="antidad[$contador]">
  84. <option value="1">1</option>
  85. <option value="2">2</option>
  86. <option value="3">3</option>
  87. <option value="4">4</option>
  88. <option value="5">5</option>
  89. </select>
  90. </td>
  91. <td>
  92. <?php echo "<input type='checkbox' name='seleccion[$contador]' value='$row[producto]'/>"; ?>
  93. </td>
  94. </tr>
  95. <?php
  96. $contador++;
  97. }//fin del while
  98. ?>
  99. <tr>
  100. <td colspan="4" class="btn"><input type="submit" value="ENVIAR" name="comprar" /></td>
  101. </tr>
  102. </table>
  103. </form>
  104. <?php mysql_free_result($resul_list_prod);?>
  105. </div>
  106. <p class="meta"></p>
  107. </body>
  108. </html>

y ya tienes los arreglos... tanto del producto como de la cantidad.......

ahora para enviarlos correctamente has asi:

enviar.php
=========
Código PHP:
Ver original
  1. <?php
  2. $nombre = $_POST['nombre'];
  3. $apellido = $_POST['apellido'];
  4. $empresa = $_POST['empresa'];
  5. $direccion = $_POST['direccion'];
  6. $telefono = $_POST['telefono'];
  7. $productos = $_POST["seleccion"];
  8. $cantidad = $_POST["cantidad"];
  9.  
  10. $header = "From: $mail\r\n";
  11. $header .= "X-Mailer: PHP/".phpversion()."\r\n";
  12. $header .= "MIME-Version: 1.0\n";
  13. $header .= "Content-Type: text/html; charset=\"utf-8\"\n";
  14.  
  15. $mensaje = "Este mensaje fue enviado por $nombre $apellido, de la empresa $empresa, direccion $direccion, telefono $telefono";
  16. if(count($productos)>0){
  17.     $mensaje .= ", y sus productos seleccionados son: ";
  18.     foreach($productos as $contador => $valor){
  19.         $mensaje .= "$valor cantidad $cantidad[$contador], ";
  20.     }
  21.     $mensaje .= substr($mensaje, 0, strlen($mensaje) - 2);
  22. }
  23. $mensaje .= "<br />Su e-mail es: $email<br />Enviado el ".date('d/m/Y');
  24.  
  25. echo "$mensaje<br /><br />"; //de testeo
  26. mail("[email protected]", "venta", $mensaje, $header);
  27. echo "<h3>Muchas Gracias en breve nos comunicamos con usted</h3>";
  28. ?>

espero te sirva muy bien.

Muchas gracias por el karma.....

Suerte.
__________________
Atte. MasterOjitos :ojotes:
Todo sobre Programación Web
Las ultimas tendencias en Efectos y Recursos Web: MasterOjitos Blog