Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
邮件正文中的PHP变量未显示在实际电子邮件中_Php_Email_Variables_Session_Phpmailer - Fatal编程技术网

邮件正文中的PHP变量未显示在实际电子邮件中

邮件正文中的PHP变量未显示在实际电子邮件中,php,email,variables,session,phpmailer,Php,Email,Variables,Session,Phpmailer,起初,phpmailer没有从我的这个页面发送邮件,但我设法修复了它。这一次,消息发送到email变量,除页面中已声明的变量外的所有其他内容都不会显示 页面的源代码如下: <?php require_once("connection.php"); ?> <?php $date_order = gmdate('M d, Y'); $time_order = gmdate('H:i:s'); $cust_ID = $_SESSION['cust_ID']; $order_ref

起初,phpmailer没有从我的这个页面发送邮件,但我设法修复了它。这一次,消息发送到email变量,除页面中已声明的变量外的所有其他内容都不会显示

页面的源代码如下:

<?php
require_once("connection.php");
?>

<?php

$date_order = gmdate('M d, Y');
$time_order = gmdate('H:i:s');
$cust_ID = $_SESSION['cust_ID'];
$order_ref = $_SESSION['order_ref'];

$query1 = mysql_query("SELECT * FROM order_receipts WHERE   order_ref='$order_ref'");
$num1 = mysql_num_rows($query1);

if($num1<1)
{
$query = mysql_query("INSERT INTO order_receipts      (order_ref,cust_id,date_order,time_order) VALUES ('$order_ref','$cust_ID','$date_order','$time_order')");

}

$query2 = mysql_query("SELECT * FROM personal_details WHERE id='$cust_ID'");
while($rows = mysql_fetch_assoc($query2))
{
$title = $rows['title'];
$first_name = $rows['first_name'];
$last_name = $rows['last_name'];
$middle_name = $rows['middle_name'];
$email_address = $rows['email_address'];
$fullname = $title." ".$first_name." ".$middle_name." ".$last_name;
}

$query3 = mysql_query("SELECT * FROM order_details WHERE order_ref='$order_ref' AND customer_id = $cust_ID");
while($row2 = mysql_fetch_assoc($query3))
{
$title = $row2['title'];
$product_sample = $row2['product_sample'];
$dress_type = $row2['dress_type'];
$name_of_dress = $row2['name_of_dress'];
$sewing_end_date = $row2['sewing_end_date'];
$service_charge = $row2['service_charge'];
$amount_paid = $row2['amount_paid'];
$prod_desc = $row2['prod_desc'];
$date_order = $row2['date_order'];
$sewing_start_date = $row2['sewing_start_date'];
$sumtotal += $rows2['service_charge'];
$sumadvance += $rows2['amount_paid'];
}

require("/home/sewsoftc/public_html/PHPMailer_5.2.0/class.smtp.php");

require("/home/sewsoftc/public_html/PHPMailer_5.2.0/class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP();                                      
$mail->Host = "localhost";  
$mail-> Port = 587;
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;     // turn on SMTP authentication
$mail->SMTPSecure = 'tls';  
$mail->Username = "sender@mail.com";  // SMTP username
$mail->Password = "sender_password"; // SMTP password

$mail->From = "noreply@mail.com";
$mail->FromName = "Unania Ltd.";
$mail->AddAddress("$email_address", "$fullname");
$mail->AddReplyTo("admin@mail.com", "Information");
$mail->AddEmbeddedImage  ("images/una_mail.png","unanialogo","images/una_mail.png");
$mail->AddEmbeddedImage("$product_sample","ordersample","$product_sample");

$mail->WordWrap = 50;                                 
$mail->IsHTML(true);                                 

//$message = file_get_contents("msg.php");
$mail->Subject = "Order Notification From Unania Couture";
$mail->Body    = "<table>
<tr style='background:#D71576; height:140px; width:100%;'>
<td style='padding:22px 0; text-align:center;'><img src='cid:unanialogo' /></td>
</tr>

<tr style='color:#056FFF; font-size:18px; font-weight:bold;'>
<td><br />Dear <?php echo ''.$fullname; ?>,<br /><br /><span     style='color:#636D76; font-size:16px; font-weight:normal;'>Thank you for ordering our tailoring service. The order details of your dress are enclosed in the receipt below for your record.</span><br /></td></tr>

<tr>
<td>
<table style='width:90%; margin:0 auto; font-family:tahoma; font-size:12px;' align='center'>
<tr style='background:#056FFF; color:#fff; font-size:16px;'>
<td style='width:19%; font-size:113%; font-weight:bold; font-family:calibri;'>Name</td>
<td colspan='3' style='width:49%; background: #3B88F3;'><?php    echo ''.$title.' '.$first_name.' '.$middle_name.' '.$last_name; ?></td>
<td style='width:19%; font-size:113%; font-weight:bold; font-family:calibri;'>Invoice No</td>
<td style='width:15%; background: #3B88F3;'><?php echo ''.$order_ref; ?></td>
</tr>
<?php
while($row2 = mysql_fetch_assoc($query3))
{?>
<tr style='background:#fff; color:#000; font-size:16px;'>
<td style='width:19%; font-size:113%; font-weight:bold; font-family:calibri;'>Dress Style</td>
<td  style='width:19%; background:#E5DDDD;'><?php echo ''.$dress_type.' - '.$name_of_dress; ?></td>
<td style='width:16%; font-size:113%; font-weight:bold; font-family:calibri;'>Projected Date of Completion</td>
<td style='width:12%; background:#E5DDDD;'><?php echo ''.$sewing_end_date; ?></td>
<td style='width:19%; font-size:113%; font-weight:bold; font-family:calibri;'>Service Charge</td>
<td style='width:15%; background:#E5DDDD;'><?php echo ''.$service_charge; ?></td>
</tr>

<tr style='background:#056FFF; color:#fff; font-size:16px;'>
<td style='width:19%; font-size:113%; font-weight:bold; font-family:calibri;'>Dress Description</td>
<td colspan='3' style='width:49%; background: #3B88F3;'><?php   echo ''.$prod_desc; ?></td>
<td style='width:19%; font-size:113%; font-weight:bold; font-family:calibri;'>Dress Sample</td>
<td style='width:15%; background: #3B88F3;'><img src='cid:ordersample' width='50' height='50'/></td>
</tr>
<?php } ?> 
<tr style='background:#fff; color:#000; font-size:16px;'>
<td style='width:19%; font-size:113%; font-weight:bold; font-family:calibri;'>Total Charge</td>
<td colspan='3' style='width:49%; background: #E5DDDD;'><?php echo ''.$sumtotal; ?></td>
<td style='width:19%; font-size:113%; font-weight:bold; font-family:calibri;'>Advance Payment</td>
<td style='width:15%; background:#E5DDDD;'><?php echo ''.$sumadvance; ?></td>
</tr>

<tr style='background:#056FFF; color:#fff; font-size:16px;'>
<td style='width:19%; font-size:113%; font-weight:bold; font-family:calibri;'>Balance Remaining</td>
<td colspan='3' style='width:49%; background: #E5DDDD;'>₦<?php echo ''.$balance_remaining = -($sumtotal - $sumadvance); ?></td>
<td style='width:19%; font-size:113%; font-weight:bold; font-family:calibri;'>Order Date</td>
<td style='width:15%; background:#3B88F3;'><?php echo ''.$order_date; ?></td>
</tr>

</table>
</td>
</tr>

<tr>
<td><br /><span style='color:#636D76; font-size:16px; font-weight:normal;'>
Please note that all outstanding payments will be duly collected when the dress is completed and ready to be collected. We hope to bring you an unequaled satisfactory service. We will keep in touch with you to let you know when your dress is completed.</span>
<br /><br /><br /><span style='color:#637894; font-size:15px; font-weight:normal;'>This email you received is an automated message sent to you by Unania Couture in response of any activity that concerns you within the company.</span><br /><span style='color:#637894; font-size:15px; font-weight:normal;'>Do not reply back to this mail, as our administration staff will not be able to give any feedback following your reply, but contact us on admin@sew-soft.com</span><br /><br /><br /><span style='color:#637894; font-size:15px; font-weight:normal;'>To unsubscribe from automatic email notification, please click this link <a href='#'>Unsubscribe me</a></span>
</td></tr>

</table>";

if($mail->Send()) {
echo "Message sent!";
} else {
 echo "Mailer Error: " . $mail->ErrorInfo;
}

//echo $_SESSION['order_ref'];
//echo "<br />".$fullname;

//echo("<script>location.href = 'receipt2.php?order_ref=$order_ref&cust_ID=$cust_ID';</script>");

?>


就像@EdCottrell所说的,你必须摆脱
尝试格式化你的问题,答案将是显而易见的。请你也试着做
mysql.*
函数已经过时,而且不安全。使用或代替。此外,对于@EdCottrell,您可能希望(公开地)去掉问题中客户的公司名称,因为他肯定不希望看到自己的名字出现在编程网站上……非常感谢(Ed Cottrell),这很有效。但是对于mysqli_查询,我不太熟悉,我的同事说它是面向对象的php,现在,我可以很好地使用旧的表单过程化php编程,我可以在不声明类的情况下使用函数吗。你能给我介绍一些我擅长的东西吗。我会的appreciate@optimalresource例如你也可以用图书馆来做那件事。一个非常好的使用mysqli的是来自。阅读github上的全部文档,就可以开始了!
$mail->Body    = "<table>
<tr style='background:#D71576; height:140px; width:100%;'>
<td style='padding:22px 0; text-align:center;'><img src='cid:unanialogo' /></td>
</tr>
<tr style='color:#056FFF; font-size:18px; font-weight:bold;'>
<td><br />Dear {$fullname},<br /><br /><span     style='color:#636D76; font-size:16px; font-weight:normal;'>Thank you for ordering our tailoring service. The order details of your dress are enclosed in the receipt below for your record.</span><br /></td></tr>

<tr>
<td>
<table style='width:90%; margin:0 auto; font-family:tahoma; font-size:12px;' align='center'>
<tr style='background:#056FFF; color:#fff; font-size:16px;'>
<td style='width:19%; font-size:113%; font-weight:bold; font-family:calibri;'>Name</td>
<td colspan='3' style='width:49%; background: #3B88F3;'>{$title} {$first_name} {$middle_name} {$last_name}</td>
<td style='width:19%; font-size:113%; font-weight:bold; font-family:calibri;'>Invoice No</td>
<td style='width:15%; background: #3B88F3;'>{$order_ref}</td>
</tr>";