0
I am trying to send a product table by php Mailer, but when I put the code of the table there, the values of the table are not filled, leaving only the codes appearing.
<table width="467" border="1px" bgcolor="#CCC" >
<thead>
<tr>
<th width="244" bgcolor="#CCC">Produto</th>
<th width="89" bgcolor="#CCC">Quantidade</th>
<th width="89" bgcolor="#CCC">Preço</th>
<th width="100" bgcolor="#CCC">SubTotal</th>
</tr>
</thead>
<form action="?acao=up" method="post">
<tbody>
<?php
error_reporting (E_ALL & ~ E_NOTICE & ~ E_DEPRECATED);
if(count($_SESSION['checkout']) == 0){
echo '
<tr>
<td colspan="5">Não há produto no carrinho</td>
</tr>
';
}else{
require("banco.php");
$server = "localhost";
$db = "clientes"; // Indique o nome do banco de dados que será aberto
$usuario = "root"; // Indique o nome do usuário que tem acesso
$password = ""; // Indique a senha do usuário
//1º passo - Conecta ao servidor MySQL
$conect = mysql_connect($server,$user,$password ) or die (mysql_error());
//2º passo - Seleciona o Banco de Dados
$select_db = mysql_select_db($db) or die (mysql_error());
$total = 0;
foreach($_SESSION['checkout'] as $id => $qtd){
$sql = "SELECT * FROM produtos WHERE id= '$id'";
$qr = mysql_query($sql) or die(mysql_error());
$ln = mysql_fetch_assoc($qr);
$nome = $ln['nome'];
$preco = number_format($ln['preco'], 2, ',', '.');
$sub = number_format($ln['preco'] * $qtd, 2, ',', '.');
$total += $ln['preco'] * $qtd;
echo '
<tr>
<td>'.$nome.'</td>
<td>'.$qtd.'</td>
<td>R$ '.$preco.'</td>
<td>R$ '.$sub.'</td>
</tr>
';
}
$total = number_format($total, 2, ',', '.');
echo '
<tr>
<td colspan="4">Total :
R$ '.$total.'
</td>
</tr>
';
}
?>
</tbody>
</form>
</table>
This is the codic of php Mailer:
<?php
require "PHPMailer-master/PHPMailerAutoload.php";
$nome = $_POST['nome'];
$email = $_POST['email'];
$tabela = $_POST['tabela'];
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '***********'; // SMTP username
$mail->Password = '***********'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to0
$mail->setFrom('[email protected]', '*******');
$mail->addAddress('***********');
$mail->addAddress($email); // Add a recipient
//$mail->addAddress('************'); // Name is optional
//$mail->addReplyTo('[email protected]', 'Information');
//$mail->addCC('[email protected]');
//$mail->addBCC('[email protected]');
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $email;
$mail->Body = $nome;
$mail->Subject = "Compra efeituada com sucesso!!!";
$mail->Body = "<!DOCTYPE html>
<html lang='pt-br'>
<head>
<meta charset='utf-8'/>
<meta content='width=device-width, initial-scale=1, maximum-scale=1' name='viewport'>
<title>Título da Página (Estrutura básica de uma página com HTML 5)</title>
<link href='css/seu-stylesheet.css' rel='stylesheet'/>
<script src='scripts/seu-script.js'></script>
</head>
<body>
<font color='black' face='arial' size='4px'>Olá, $nome, $total<p>
<h3>Recebemos o seu pedido!</h3><p> Deposite Nessa Conta o Valor da compra: 4752564814 01 Apos o deposito entraremos em contato para o envio!
</font>
$tabela;
</html>
";
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo"<center><font color = black>Email ou senha invalidos!!Aguarde um instante para tentar novamente.</font></center>";
echo "<script>LoginFailed()</script>";
}else{
echo"<center><h1><font color = black>Você foi autenticado com sucesso!Aguarde um instante que você sera redirecionado a pagina Home.</font></h1></center>";
echo"<script>LoginSucessfully()</script>";
}
?>
No use sending external CSS code (.css) or putting Javascript in the email because it won’t work.
– Sam
So what would be the solution to this?
– Pottker Mil_Grau
I did not see in the form any field to be sent via POST.
– Sam
Like I tried to put maias n got, can give an example of how I can put?
– Pottker Mil_Grau