dongrouli2667 2014-02-23 07:50
浏览 24
已采纳

以电子邮件形式回显变量[关闭]

I want to know why the partsname and qty don't echo inside an email message body.

Here is my code:

<?php
    include('../config.php');
    $roomid = $_POST['roomid'];
    $status=$_POST['status'];
    $tc=$_POST['transactioncode'];
    mysql_query("UPDATE athan_orders SET status='$status' WHERE id='$roomid'");
    header("location: viewords.php");

    mysql_query("SELECT * FROM athan_members where id='$roomid'");
    $recepient=$_POST['id'];
    mysql_query("SELECT * FROM orderdetails where transactioncode = '$tc'");
    $partsname=$_POST['partsname'];
    $qty=$_POST['qty'];
        $to = "$recepient"; //enter the recipients email address here
        $subject = "Order Confirmed"; //email subject
        $message = "
        <html>
        <head>
        <title>Order Confirmed</title>
        </head> 
        <body>
        <p>Your Order at Athan Motorcycles has been confirmed by the admin. Please contact the company for the details and verification of your order.</p>
        <table>
                  <tr >
                    <td><div>&nbsp;&nbsp;&nbsp;&nbsp;Products</div></td>
                    <td>Qty</td>
                  </tr>
        </table>
                  <tr>
                  <td>"echo "$partsname"";
                  <td>"echo "$qty"";
                  </td>
                  </td>
                  </tr>
        <table>
        <tr>
        <th>Thank you!</th>
        <th>-Athan Motorcycles</th>
        </tr>
        <tr>
        <td></td>
        <td></td>
        </tr>
        </table>
        </body>
        </html>
        ";
        // Always set content-type when sending HTML email
        $headers = "MIME-Version: 1.0" . "
";
        $headers .= "Content-type:text/html;charset=iso-8859-1" . "
";
        // More headers
        $fromemail = "melvin.napoles@yahoo.com"; //enter senders email address here
        $headers .= "From: <". $fromemail . ">
";
        //$ccemail = ""; //cc email address
        //$headers .= "Cc: $ccemail" . "
";
        if (mail($to,$subject,$message,$headers) == TRUE){
        print "Success!";
        }else{
        print "Error!";
        }


?>

so i query the parts name and qty from the order details and make a variable to them. then i inserted it inside the email form. Is it correct or there is something wrong from calling the variables?

  • 写回答

2条回答 默认 最新

  • drux41001 2014-02-23 07:52
    关注

    No its not correct, you can't use echo inside variable. Use this to concenate variables:

        $message = "
        <html>
        <head>
        <title>Order Confirmed</title>
        </head> 
        <body>
        <p>Your Order at Athan Motorcycles has been confirmed by the admin. Please contact the company for the details and verification of your order.</p>
        <table>
                  <tr >
                    <td><div>&nbsp;&nbsp;&nbsp;&nbsp;Products</div></td>
                    <td>Qty</td>
                  </tr>
        </table>
                  <tr>
                  <td>$partsname 
                  <td>$qty
                  </td>
                  </td>
                  </tr>
        <table>
        <tr>
        <th>Thank you!</th>
        <th>-Athan Motorcycles</th>
        </tr>
        <tr>
        <td></td>
        <td></td>
        </tr>
        </table>
        </body>
        </html>
        ";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?