finalizar.php, , esta recoge los datos de la compra
Código PHP:
Ver original
<table width="721" border="0" align="center"> <tr> <td width="603">Deberan remitirnos el comprobante de la transferencia a este numero de IBAN: 12345678912</td> </tr> </table> <nav class="menu2"> <menu> <li><a href="./index.php">Inicio</a></li> <li><a href="#" class="selected">Admin</a></li> <li><a href="#" >Agregar</a></li> <li><a href="#">Salir</a></li> </menu> </nav> <table width="661" align="center"> <tr> <td width="464" align="center"><h2>Compra realizada</h2></td> <td width="185"><?php echo '<a href="./compras/compras.php" class="comprar">Ver Mis compras</a>'?></td> <a href="compras/compras.php">ver compras</a> </tr> </table> <table width="611" height="19" border="0px" align="center" cellpadding="0" cellspacing="0" id="tabla"> <tr align="center"> <td width="145" bgcolor="#E9E9E9">Nombre Producto</td> <td width="80"bgcolor="#E9E9E9">Precio</td> <td width="95"bgcolor="#E9E9E9">Cantidad</td> <td width="107"bgcolor="#E9E9E9">Subtotal</td> <td width="184"bgcolor="#fafafa"></td> </tr> <?php ?> <?php $total = 0; $cantidad = 0; $tabla = 0; $numeroventa=0; if($numeroventa !=$f['numeroventa']){ }?> <?php $numeroventa=$f['numeroventa']; echo '<tr align="center" bgcolor="#D8F9FE"> <td id="n">'.$f['nombre'].'</td> <td align="right">'.$f['precio'].' Euros </td> <td id="c">'.$f['cantidad'].'</td> <td align="right" >'.$f['subtotal'].' Euros </td> </tr>'; $total += $f['subtotal']; $cantidad += $f['cantidad']; $tabla += $f['nombre']; }?><br /> <table width="440" align="center"><br /> <tr> <td width="220"></td> <td width="140"><strong>total: <?php echo $total; ?> Euros</strong></td> <td></td> </tr> </table> </table><br /> <form id="formulario" method="post" action="mail.php" enctype="multipart/form-data"> <table width="513" height="130" align="right" bgcolor="#EEEEEE"> <tr> <td width="56" height="15">Email: </td> <td width="146"> <input type="email" name="email" class="campo" required></td> <td width="61"> <label>Nombre:</label></td> <td width="142"><input name="nombre" type="text" class="campo" ></td> </tr> <tr> <td><label>Ciudad:</label></td> <td><input type="text" name="ciudad" class="campo" required ></td> <td><label>Direccion:</label></td> <td><input type="text" name="direccion" class="campo" required></td> </tr> <tr> <td><label>Telefono:</label></td> <td><input type="text" name="telefono" class="campo" required></td> <td> <label>Asunto:</label></td> <td><input name="asunto" type="text" class="campo" value="Compra realizada" readonly="readonly"></td> </tr> <tr> <td><input name="cantidad" type="hidden" value="" > <input name="tabla" type="hidden" value="" > </td> </tr> <tr> <td height="34"> </td> <td><input id="submit" type="submit" name="enviar" value="Enviar mail"></td> </tr> </table></form>
mail.php recoge , procesa y manda email
Código PHP:
Ver original
<?php //Librerías para el envío de mail include_once('phpmailer/class.phpmailer.php'); include_once('phpmailer/class.smtp.php'); //Recibir todos los parámetros del formulario $para = $_POST['email']; $asunto = $_POST['asunto']; $mensaje = $_POST['mensaje']; $direccion= $_POST['direccion']; $ciudad = $_POST['ciudad']; $telefono = $_POST['telefono']; $nombre = $_POST['nombre']; $cantidad = $_POST['cantidad']; //Este bloque es importante $mail = new PHPMailer(); $mail->IsSMTP(); $mail->SMTPAuth = true; $mail->SMTPSecure = "ssl"; $mail->Host = "smtp.gmail.com"; $mail->Port = 465; //Nuestra cuenta $mail->Password = 'password xxxx'; //Agregar destinatario $mail->AddAddress($para); $mail->Subject = $asunto; $mail->Body = "mensaje:$mensaje <br />". "cantidad:$cantidad <br />". "tabla:$tabla <br />". "<font><strong>Estos son sus datos \n <br /></strong></font>". "direccion: $direccion \n <br />". "ciudad:$ciudad <br />". "nombre:$nombre <br />". "telefono: $telefono <br /> "; $mail->direccion=$direccion; $mail->telefono=$telefono; //Para adjuntar archivo $mail->IsHTML(true); //$mail->MsgHTML($mensaje,$asunto,$direccion,$direccion); //Avisar si fue enviado o no y dirigir al index if($mail->Send()) { echo'<script type="text/javascript"> alert("Enviado Correctamente"); window.location="finalizar.php" </script>'; } else{ echo'<script type="text/javascript"> alert("NO ENVIADO, intentar de nuevo"); window.location="finalizar.php" </script>'; } ?>