druybew06513 2013-12-19 10:39
浏览 38

PHP表单被发送到电子邮件不生成正确的输出?

I have the following. Im trying to send a table of data through to an email address but this code is not working I get the following error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

Here is the processing code:

<?php 
$headers = 'MIME-Version: 1.0' . "
";
$headers .= 'Content-Type: text/html; charset=ISO-8859-1' . "
";
$headers .= "From: Sales Rep <darrenascas@casc.com>
";
$subject = 'Email report';

 $to = 'domscinic.masccafee@emaccasre.com'; 
 $subject = "Web Contact Data"; 




$body = "

<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
<table border='1'>
    <thead>
        <tr>
<?php

     if (!empty($_POST)) {

    echo '<tbody>';
    foreach($_POST['itemCode'] as $row => $item) {
     echo'<tr>';
     echo '<td>' . htmlspecialchars($_POST['itemCode'][$row]) . "" . "</td>";
     echo '<td>' . htmlspecialchars($_POST['itemDesc'][$row]) . "" . "</td>";
     echo '<td>' . htmlspecialchars($_POST['itemQty'][$row]) . "" . "</td>";
     echo '<td>' . '&#8364;' . htmlspecialchars($_POST['itemPrice'][$row]) . "" . "</td>    ";
     echo '<td>' . '&#8364;' . htmlspecialchars($_POST['itemLineTotal'][$row]) . "" . "</td>";
    echo'<tr>';


}
echo '</tbody>';

        }

    ?>
        </tr>
    </thead>
</table>
</body>
</html>
";




 $send = mail($to, $subject, $body, $headers); 
 if($send){
   // header( "Location:index.php" );
    } else {
        print "We encountered an error sending your mail, please try again"; 
    } 
?> 

Could someone please advise? I really need to get this working today. Please please someone help.

  • 写回答

3条回答 默认 最新

  • douaipi3965 2013-12-19 10:46
    关注

    Do this:

        $body = "
    
    <html>
    <head>
    <title>HTML email</title>
    </head>
    <body>
    <p>This email contains HTML Tags!</p>
    <table border='1'>
        <thead>
            <tr>";
    
         if (!empty($_POST)) {
    
        $body .= '<tbody>';
        foreach($_POST['itemCode'] as $row => $item) {
         $body .= '<tr>';
         $body .= '<td>' . htmlspecialchars($_POST['itemCode'][$row]) . "" . "</td>";
         $body .= '<td>' . htmlspecialchars($_POST['itemDesc'][$row]) . "" . "</td>";
         $body .= '<td>' . htmlspecialchars($_POST['itemQty'][$row]) . "" . "</td>";
         $body .= '<td>' . '&#8364;' . htmlspecialchars($_POST['itemPrice'][$row]) . "" . "</td>    ";
         $body .= '<td>' . '&#8364;' . htmlspecialchars($_POST['itemLineTotal'][$row]) . "" . "</td>";
        $body .='<tr>';
    
    
    }
    $body .= '</tbody>';
    
            }
    
    $body .= "</tr>
        </thead>
    </table>
    </body>
    </html>
    ";
    
    评论

报告相同问题?

悬赏问题

  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条