PHP - Enviar array por mail en php

 
Vista:

Enviar array por mail en php

Publicado por Belén (1 intervención) el 19/06/2014 08:14:07
Buenas, que tal? Les comento mi problema, estoy programando una web con carrito de compras, la persona compra, todo perfecto, el problema es que cuando envio el array por mail nunca me aparece el ultimo dato que agregué.. Si alguien pudiera ver el codigo y decirme donde está el error se lo agradeceria mucho.. Gracias!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
mysql_select_db($database_famota1, $famota1);
$consulta= "SELECT idproducto FROM pedido_carrito WHERE transaccion_efectuada= 0 AND 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 $key => $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>';
 
 
$mensaje2='<html><body>';
$mensaje2 .='<table border="1" align="center" class=""><tr><td width="35">Id</td><td width="59">Nombre</td><td width="64">Cantidad</td><td width="42">Precio</td></tr>';
$mensaje2 .='<tr><td>';
 
$mensaje2 .='</td><td>';
 
$mensaje2 .='</td><td>';
 
$mensaje2 .= '</td><td>';
 
$mensaje2 .= '</td></tr>';
$mensaje2 .= '<tr></tr><tr><td></td><td></td><td></td><td>Total: $' .$total. '</td></tr>';
$mensaje2 .='</table>';
$mensaje2 .='</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= "bilutrianta@gmail.com";
$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");
 
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder