簡體   English   中英

我需要以表格形式向用戶發送下訂單的副本

[英]I need to send user a copy of the placed order in the form

我在我的訂單中使用以下php代碼

除了所有者郵件之外,我還需要向用戶發送他/她的訂單的副本。 我不知道如何在$ recepient中編寫代碼,以便還將副本發送給用戶。 我需要使用“ $ Email”作為用戶電子郵件ID。 請給我建議編寫代碼。

我的訂單表PHP代碼如下:

       <?php
      $Email = @trim(stripslashes($_POST['Email']));

      $Name = $_POST['Name'];
      $Email = $_POST['Email'];
      $Business = $_POST['Business'];
      $phone= $_POST['phone'];
      $productid= $_POST['productid'];
      $producttype= $_POST['producttype'];
      $Productquantity= $_POST['Productquantity'];
      $Shippingaddress= $_POST['Shippingaddress'];
      $Message = $_POST['Message'];

     $formcontent= 
    "$Name is sending you a request for the product enquiry.  \n
       Details of  the Product Enquiry person are as follows- \n
     Name: $Name \n
     Contact Number: $phone \n
     Email: $Email \n
     Business Name/Company Name: $Business \n
     Product Id: $productid \n
     Product Type: $producttype \n
     Product Quantity: $Productquantity \n
     Comment: $Message \n
     Shipping Address: $Shippingaddress";

     $recipient = "info@domain.com";
     $subject = "Request for Product Enquiry";
     $mailheader = "From: $Name \r\n";
     mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
    echo "<h4><font color='#2A007D'><strong><center>Thank You $Name !
                We have received your Order details and 
              we will contact you as soon as possible. 
             <br>Your Order details has been sent to your Email also.
             </center></strong></font></h4>";
     ?>

您可以使用用戶的電子郵件地址再次調用mail() ,因此:

mail($Email, $subject, $formcontent, $mailheader);

盡管您可能也想更改消息文本。

$mail = mail($recipient, $subject, $formcontent, $mailheader);

 if(!$mail)
  {
     echo <h4><font color='red'>Failed</font></h4>;
  }
  else
  {
     echo "<h4><font color='#2A007D'><strong><center>Thank You $Name ! We have received your Order details and we will contact you as soon as possible. <br>Your Order details has been sent to your Email also.</center></strong></font></h4>";
  }
?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM