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条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度