我只想发送在我的数据库中获取结果的订单内容。 但当我回应它时,它会在我的php页面上显示它。我不想要它。 我希望内容仅在用户收到时显示在电子邮件中。
这是我的代码。
while($row3 = mysqli_fetch_array($result3)){
$addresses=$row3['email'];
$to = $addresses;
$subject = "Order confirmed by Home and decor";
// message
$message = '
<html>
<body>
<table width="500" height="215" border="0">
<tr>
<th width="238" height="211" scope="col"><h1 align="left">Order # 1234</h1></p></th>
<th width="10" scope="col"></th>
<th width="243" scope="col"><p><img src="file:///D|/Programs/xampp/htdocs/images/sitelogo.PNG" width="224" height="68" align="right"></p></th>
</tr>
</table>
<table width="500" height="215" border="0">
<tr>
<th width="181" height="211" scope="col"><p align="left">Ship To:</p>
<p align="left"><?=$row3['first_name']?></p>
<p align="left"><?=$row3['address_1']?></p>
<p align="left"><?=$row3['city']?></p></th>
<th width="80" scope="col"></th>
<th width="40" scope="col"></th>
<th width="181" scope="col"><p align="left"></p>
<p align="right">Bill To:</p>
<p align="right"><?=$row3['first_name']?></p>
<p align="right"><?=$row3['address_1']?></p>
<p align="right"><?=$row3['city']?></p>
</th>
</tr>
</table>
<table width="500" height="94" border="0">
<tr>
<th height="43" scope="col"><div align="left">Order Date:</div></th>
<th scope="col"> </th>
<th scope="col"> </th>
<th scope="col"><div align="right">Shipping Method:</div></th>
</tr>
<tr>
<th width="126" height="43" scope="col"><div align="left">1/11/13</div></th>
<th width="433" scope="col"> </th>
<th width="103" scope="col"> </th>
<th width="156" scope="col"><div align="right">BEAST!</div></th>
</tr>
</table>
<table width="500" height="88" border="1">
<tr>
<th width="48" scope="col">Item</th>
<th width="264" scope="col">Product Name</th>
<th width="68" scope="col">Quantity</th>
<th width="92" scope="col">Price</th>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<hr>
<table width="500" height="227" border="0">
<tr>
<th height="43" scope="col"> </th>
<th scope="col"> </th>
<th scope="col">Subtotal:</th>
<th scope="col"> </th>
</tr>
<tr>
<th height="43" scope="col"> </th>
<th scope="col"> </th>
<th scope="col">Tax:</th>
<th scope="col"> </th>
</tr>
<tr>
<th height="43" scope="col"> </th>
<th scope="col"> </th>
<th scope="col">Shipping:</th>
<th scope="col"> </th>
</tr>
<tr>
<th height="43" scope="col"> </th>
<th scope="col"> </th>
<th scope="col">Discount:</th>
<th scope="col"> </th>
</tr>
<tr>
<th width="40" height="43" scope="col"> </th>
<th width="278" scope="col"> </th>
<th width="68" scope="col">Grand Total:</th>
<th width="96" scope="col"> </th>
</tr>
</table>
<p align="right"> </p>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Order reminder <lol@gmail.com>' . "\r\n";
mail($to, $subject, $message, $headers);
}
回声就是你想要正确地呼唤一些东西。我不希望它回应,我只想让内容出现在电子邮件中而不回应它。
答案 0 :(得分:1)
不要回显变量,将它们连接到字符串中。即。
$message = "Some text ".$foo." some more text';
不
$message = "Some text <?=$foo ?> some more text';
答案 1 :(得分:0)
答案 2 :(得分:0)
在邮件内容中间做了什么错误的短标签。
<?= ?>
有关短标记的详细信息,请参阅this post
我只是从
中替换所有这些东西<?php
$message '...
<p align="left"><?=$row3['first_name']?></p>
到
<?php
$message '...
<p align="left">'.$row3['first_name'].'</p>
答案 3 :(得分:0)
您可以使用Heredoc
语法:
$message =<<<EOM
<html>
<body>
...
<table width="500" height="215" border="0">
<tr>
<th width="181" height="211" scope="col"><p align="left">Ship To:</p>
<p align="left">{$row3['first_name']}</p>
<p align="left">{$row3['address_1']}</p>
<p align="left">{$row3['city']}</p></th>
...
EOM;
建议首先在htmlspecialchars()
上应用$row3
:
$row3 = array_map('htmlspecialchars', $row3);
这假设您以后不会在代码中使用$row3