PHP - no me envia la compra al correo

 
Vista:
sin imagen de perfil

no me envia la compra al correo

Publicado por Reynaldo (7 intervenciones) el 08/05/2017 16:27:55
hola... me podian ayudar trato de enviar la compra echa al correo y no me envia nada. no se que me falta

carritodecompras.php
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
session_start();
	include 'conexion.php';
	if(isset($_SESSION['carrito'])){ //
		if(isset($_GET['id'])){
			$arreglo=$_SESSION['carrito'];
			$encontro=false;
			$numero=0;
			for($i=0;$i<count($arreglo);$i++){
				if($arreglo[$i]['Id']==$_GET['id']){
					$encontro=true;
					$numero=$i;
				}
			}
			if($encontro==true){
				$arreglo[$numero]['Cantidad']=$arreglo[$numero]['Cantidad']+1;
				$_SESSION['carrito']=$arreglo;
			}else{
				$nombre="";
				$precio=0;
				$imagen="";
 
 
 
               $link = mysqli_connect("localhost", "root","","carrito");
               mysqli_select_db($link, "carrito");
               $tildes = $link->query("SET NAMES 'utf8'"); //Para que se muestren las tildes correctamente
               $re = mysqli_query($link, "select * from productos where id=".$_GET['id'])or die(mysqli_error()
				);
               while ($f=mysqli_fetch_array($re)) { // capturo lo datos de la base datos y la asigno
					$nombre=$f['nombre'];
					$precio=$f['precio'];
					$imagen=$f['imagen'];
				}
				$datosNuevos=array('Id'=>$_GET['id'], //creamos el arreglo 
					'Nombre'=>$nombre,
					'Precio'=>$precio,
					'Imagen'=>$imagen,
					'Cantidad'=>1);
 
				array_push($arreglo, $datosNuevos);
				$_SESSION['carrito']=$arreglo; //lo guardamos en la varible de sesion
 
			}
		}
 
 
 
 
	}else{
		if(isset($_GET['id'])){
			$nombre="";
			$precio=0;
			$imagen="";
		$link = mysqli_connect("localhost", "root","","carrito");
                   mysqli_select_db($link, "carrito");
                   $tildes = $link->query("SET NAMES 'utf8'"); //Para que se muestren las tildes correctamente
                   $re = mysqli_query($link, "select * from productos where id=".$_GET['id'])or die(mysqli_error()
					);
                   while ($f=mysqli_fetch_array($re)) {
				$nombre=$f['nombre'];
				$precio=$f['precio'];
				$imagen=$f['imagen'];
			}
			$arreglo[]=array('Id'=>$_GET['id'],
				'Nombre'=>$nombre,
				'Precio'=>$precio,
				'Imagen'=>$imagen,
				'Cantidad'=>1);
			$_SESSION['carrito']=$arreglo;
		}
	}
?>
<!DOCTYPE html>
<html lang="es">
<head>
	<meta charset="utf-8"/>
	<title>Carrito de Compras</title>
	<link rel="stylesheet" type="text/css" href="./css/estilos7.css">
	<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
	<script type="text/javascript"  src="./js/scripts.js"></script>
</head>
<body>
	<header>
		<img src="./imagenes/logo.png" id="logo">
		<a href="./carritodecompras.php" title="ver carrito de compras">
			<img src="./imagenes/carrito.png">
		</a>
	</header>
	<section>
		<?php
			$total=0;
			if(isset($_SESSION['carrito'])){
			$datos=$_SESSION['carrito'];
 
			$total=0;
			for($i=0;$i<count($datos);$i++){
 
	?>
				<div class="producto">
					<center>
						<img src="./producto/<?php echo $datos[$i]['Imagen'];?>"><br>
						<span ><?php echo $datos[$i]['Nombre'];?></span><br>
						<span>Precio: <?php echo $datos[$i]['Precio'];?></span><br>
						<span>Cantidad:
							<input type="text" value="<?php echo $datos[$i]['Cantidad'];?>"
							data-precio="<?php echo $datos[$i]['Precio'];?>"
							data-id="<?php echo $datos[$i]['Id'];?>"
							class="cantidad">
						</span><br>
						<span class="subtotal">Subtotal:<?php echo $datos[$i]['Cantidad']*$datos[$i]['Precio'];?></span><br>
						<a href="#" class="eliminar" data-id="<?php echo $datos[$i]['Id']?>">Eliminar</a>
					</center>
				</div>
			<?php
				$total=($datos[$i]['Cantidad']*$datos[$i]['Precio'])+$total;
			}
 
			}else{
				echo '<center><h2>No has añadido ningun producto</h2></center>';
			}
			echo '<center><h2 id="total">Total: '.$total.'</h2></center>';
			if($total!=0){
					echo '<center><a href="./compras/compras.php" class="aceptar">Comprar</a></center>;';
			}
 
		?>
		<center><a href="./">Ver catalogo</a></center>
 
 
	</section>
</body>
</html>


compras.php
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
<?php
session_start();
include "../conexion.php";
	$datos=$_SESSION['carrito'];
	$total=0;
	$tabla='<table border="1">
		<tr>
		<th>Nombre</th>
		<th>Cantidad</th>
		<th>Precio</th>
		<th>Subtotal</th>
		</tr>';
	for($i=0;$i<count($datos);$i++)
		$tabla=$tabla.'<tr>
			<td>'.$datos[$i]['Nombre'].'</td>
			<td>'.$datos[$i]['Cantidad'].'</td>
			<td>'.$datos[$i]['Precio'].'</td>
			<td>'.$datos[$i]['Cantidad']*$datos[$i]['Precio'].'</td>
			</tr>
		';
		$total=$total+($datos[$i]['Cantidad']*$datos[$i]['Precio']);
	}
	$tabla=$tabla.'</table>';
	//echo $tabla;
	$nombre="reynaldo";
	$fecha=date("d-m-Y");
	$hora=date("H:i:s");
	$asunto="Compra realizada";
	$desde="www.tupagina.com";
	$correo="reynaldo.romero9122@gmail.com";
	$comentario='
		<div style="
			border:1px solid #d6d2d2;
			border-radius:5px;
			padding:10px;
			width:800px;
			heigth:300px;
		">
		<center>
			<img src="https://yt4.ggpht.com/-3eVnkBJn2y4/AAAAAAAAAAI/AAAAAAAAAAA/hAqolVRolHc/s48-c-k-no/photo.jpg" width="300px" heigth="250px">
			<h1>Muchas gracias por comprar en mi carrito de compras</h1>
		</center>
		<p>Hola '.$nombre.' muchas gracias por comprar aquí te mando los detalles de tu compra</p>
		<p>Lista de Artículos<br>
			'.$tabla.'
			<br>
			Total del pago es: '.$total.'

		</p>
		</div>

	';
 
	//echo $comentario;
	$headers="MIME-Version: 1.0\r\n";
	$headers.="Content-type: text/html; charset=utf8\r\n";
	$headers.="From: Remitente\r\n";
	mail($correo,$asunto,$comentario,$headers);
	unset($_SESSION['carrito']);
	header("Location: ../admin.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