Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/06/2005, 14:50
Maru77
 
Fecha de Ingreso: agosto-2003
Mensajes: 524
Antigüedad: 20 años, 8 meses
Puntos: 5
Enviar mail pasando variables

Tengo un formulario en cual además de los datos nombre, dirección y teléfono, se recepcionarán una serie de artículos desde una base de datos, sería algo más o menos así:

Código HTML:
<form name="form1" method="post" action="enviar.php">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>Nombre:</td>
    <td>
        <input type="text" name="nombre" size="30">
      </td>
  </tr>
  <tr>
    <td>Direcci&oacute;n:</td>
    <td><input type="text" name="direccion" size="30"></td>
  </tr>
  <tr>
    <td>Tel&eacute;fono:</td>
    <td><input type="text" name="telefono" size="30"></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
    <td><input type="submit" name="submit" value="enviar"></td>
</table>
</form>

<?PHP

$Link=mysql_connect ("localhost", "", "") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("base")or die("Error select db ".mysql_error());

foreach($HTTP_POST_VARS as $varname => $value)
        $formVars[$varname]=$value;

include("db.php");

$result = mysql_query("SELECT * FROM emp INNER JOIN prod ON emp.prodid = prod.productid WHERE emp.empreid = '" . Getemp() . "' ORDER BY prod.productnom ASC");

while($row = mysql_fetch_array($result))
	{
	 echo "<td>".$row["productnom"]."</td> \n"; 
	 echo "<td>".$row["cant"]."</td> \n";
	 echo "<td>".$row["precio"]."</td> \n";
	 echo "</tr> \n";
	}
?>
hasta acá todo perfecto... pero lo que quiero lograr es que esas variables: productnom, cant y precio se recepcionen en el mail junto con los otros datos del formulario.

Para el formulario tengo este código:

Código PHP:
<?
    $cuerpo 
.= "<b>Nombre:</b> " $_POST["nombre"] . "\n"
    
$cuerpo .= "<b>Dirección:</b> " $_POST["direccion"] . "\n"
    
$cuerpo .= "<b>Teléfono:</b> " $_POST["telefono"] . "\n";  
    
$cuerpo  nl2br($cuerpo); 
    
$to "[email protected]"
    
$subject "$nombre - Consulta"
    
$mailheader "MIME-Version: 1.0 \r\n"
    
$mailheader .= "Content-type: text/html; charset=iso-8859-1 \r\n"
    
$mailheader .= "From: Formulario de Consulta \r\n"
    
$mailheader .= "Return-path: \r\n"
    
$mailheader .= "X-Priority: 1 \r\n"
    
$mailheader .= "X-MSMail-Priority: High \r\n"
    
$mailheader .= "X-Mailer: PHP/".phpversion()." \n"
  
    if (
mail ($to,$subject,$cuerpo,$mailheader)) 
?>
El tema es que no se como pasar los otros valores productnom, cant y precio, es muy complejo???

La verdad es que busqué ejemplos, pero no encontré nada que me soluciones el inconveniente, ojalá alguno de ustedes me puedan ayudar...

Gracias!!!
__________________
Saludos!!!
Maru.-