2013-12-18 126 views
0

我有以下代码:流程订单发送电子邮件

<table class="table table-striped" id="itemsTable"> 
       <thead> 
       <tr> 
        <th></th> 
        <th>Item Code</th> 
        <th>Description</th> 
        <th>Qty</th> 
        <th>Price</th> 
        <th>Total</th> 
       </tr> 
       </thead> 
       <tbody> 
       <tr class="item-row"> 
        <td></td> 
        <td><input type="text" name="itemCode[]" value="" class="input-medium" id="itemCode" 
           tabindex="1"/> 
        </td> 
        <td><input type="text" name="itemDesc[]" value="" class="input-large" id="itemDesc" 
           readonly="readonly"/></td> 
        <td><input type="text" name="itemQty[]" value="" class="input-mini" id="itemQty" tabindex="2"/> 
        </td> 
        <td> 
         <div class="input-prepend input-append"><span class="add-on">&#8364;</span> 
         <input 
           name="itemPrice[]" 
           class=" input-small" 
           id="itemPrice" 
           type="text"></div> 
        </td> 
        <td> 
         <div class="input-prepend input-append"><span class="add-on">&#8364;</span><input 
           name="itemLineTotal[]" class=" input-small" id="itemLineTotal" type="text" 
           readonly="readonly"></div> 
        </td> 
       </tr> 
       </tbody> 
      </table> 

什么是通过PHP来处理输入通过电子邮件发送nicley格式化成表中的顺序最好方法是什么?这是一个订单,我需要简单地发送到电子邮件一旦完成

这里是我的处理代码:

<?php 
$to = $_REQUEST['xxx'] ; 
$from = $_REQUEST['Email'] ; 
$name = $_REQUEST['Name'] ; 
$headers = "From: $from"; 
$subject = "Web Contact Data"; 

$fields = array(); 
$fields{"itemCode"} = "Code"; 
$fields{"itemDesc"} = "Description"; 
$fields{"itemPrice"} = "Price"; 

$body = "We have received the following information:\n\n"; 

foreach($fields as $a => $b){ 
$body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); 
} 

$headers2 = "From: [email protected]"; 
$subject2 = "Thank you for contacting us"; 
$autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at www.oursite.com"; 


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

此代码不能正常工作,请帮助

+1

“不工作”。一些更详细的信息可能会帮助你获得答案。 – Michael

回答

0

哪里

$to = $_REQUEST['xxx'] ; 

从哪里来?我的猜测是,你可以将其设置为固定的,你也许并不需要一个动态的电子邮件地址,所以是这样的:

$to = '[email protected]'; 

但迈克尔在你的问题的反应所提到的,我们不能直到你告诉我们哪个部分不工作/你收到什么错误,等等。

+0

我收到一封电子邮件,但是只是代码:描述:价格:没有数据通过电子邮件发送 – Dom

+0

当您回显$ body var时,您是否看到正确的数据?如果不是,你知道去哪里看。 – jvv

0

要用这种方式处理表单,你需要在你的标记的某个地方有一个表单元素来处理。

<form method="POST" action="yourSecondScript.php"> 
    your first markup here 
    <input type="submit"> 
<form> 

然后为了使电子邮件很好,你需要将电子邮件标题设置为html。

$headers = 'MIME-Version: 1.0' . "\r\n"; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
$headers .= "From: " . $_REQUEST['Name'] . ">\r\n"; 

mail($to, $subject, $body, $headers); 
相关问题