Buenas! Les comento mi problema.. Tengo una pagina con un carrito de compras, todo funciona perfecto, pero cuando intento enviar por mail la información del pedido al cliente, siempre hay un dato que no se envia, por ejemplo, si compra un solo producto, no se envia ninguna fila, y si compra mas de uno, el ultimo producto que seleccionó no se envia.. Les dejo el codigo a ver si me pueden ayudar, me estoy volviendo literalmente loca! Muchas gracias :)
Código PHP:
mysql_select_db($database_famota1, $famota1);
$consulta= "SELECT idproducto FROM pedido_carrito WHERE id_usuario=".$varIdUsuario."";
$resultado=mysql_query($consulta, $famota1) or die(mysql_error());
$row_resultado= mysql_fetch_assoc($resultado);
$id= array();
$producto= array();
$cantidad= array();
$precio= array();
while($row_resultado = mysql_fetch_assoc($resultado)){
$id[]=$row_resultado['idproducto'];
$producto[]= nombre($row_resultado['idproducto']);
$cantidad[]= cantidad($row_resultado['idproducto']);
$precio[]= precio($row_resultado['idproducto']);
}
$mensaje3='<style type="text/css">
<!--
tabla {
font-family: Verdana, Geneva, sans-serif;
font-size: 18px;
text-align: center;
}
-->
</style>';
$mensaje3 .='<html><body>';
$mensaje3 .='<table border="1" align="center" class="tabla"><tr><td width="35">Id</td><td width="200">Nombre</td><td width="50">Cantidad</td><td width="50">PrecioxUnidad</td></tr>';
$mensaje3 .='<tr><td>';
foreach($id as $res){
$mensaje3 .="<pre>".$res."</pre>";
}
$mensaje3 .='</td><td>';
foreach($producto as $res2){
$mensaje3 .= "<pre>".$res2."</pre>";
}
$mensaje3 .= '</td><td>';
foreach($cantidad as $res3){
$mensaje3 .= "<pre>".$res3."</pre>";
}
$mensaje3 .= '</td><td>';
foreach($precio as $res4){
$mensaje3 .= "<pre>".$res4."</pre>";
}
$mensaje3 .= '</td></tr>';
$mensaje3 .= '<tr></tr><tr><td></td><td></td><td></td><td>Total: $' .$total.'</td></tr>';
$mensaje3 .='</table>';
$mensaje3 .='</body></html>';
$nombre= $_POST["nombre_usuario"];
$apellido= $_POST["apellido_usuario"];
$domicilio= $_POST["domicilio_usuario"];
$localidad= $_POST["localidad_usuario"];
$telefono= $_POST["telefono_usuario"];
$mail= $_POST["mail_usuario"];
$laser_mail= "[email protected]";
$asunto= "Tu compra se ha realizado con éxito";
$asunto2= "$nombre ha realizado una compra";
$headers= "MIME-Version:1.0;\r\n";
$headers .= "Content-type: text/html; r\n charset= iso-8859-1; \r\n";
$headers .= "From: $laser_mail \r\n";
$headers .= "To: $mail; \r\n Subject: $asunto \r\n";
$headers2= "MIME-Version:1.0;\r\n";
$headers2 .= "Content-type: text/html; r\n charset= iso-8859-1; \r\n";
$headers2 .= "From: $laser_mail \r\n";
$headers2 .= "To: $$laser_mail; \r\n Subject: $asunto \r\n";
if(mail($mail,$asunto,$mensaje3,$headers)){
$deleteSQL = sprintf("DELETE FROM pedido_carrito WHERE id_usuario=".$_SESSION['MM_idUsuario']."");
mysql_select_db($database_famota1, $famota1);
$Result1 = mysql_query($deleteSQL, $famota1) or die(mysql_error());
mail($laser_mail,$asunto2,$mensaje3,$headers2);
header("Location: felicitaciones.php");
}