PHP表单处理未发送正确的电子邮件

PHP表单处理未发送正确的电子邮件,php,mysql,forms,Php,Mysql,Forms,我有下面的表格,它是通过数据库中的autosuggest填充的 <table class="table table-striped" id="itemsTable"> <thead> <tr> <th></th> <th>Item Code</th>

我有下面的表格,它是通过数据库中的autosuggest填充的

<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>
                    <form id="itemsForm" action="services/processOrder.php" method="post">
                    <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查询:

<?php

require_once('db_connection.php');
$return_arr = array();

$param = $_GET["term"];

$query = "SELECT field_id_5, exp_weblog_titles.title, field_id_57  
          FROM exp_weblog_data, exp_weblog_titles 
          WHERE exp_weblog_titles.entry_id = exp_weblog_data.entry_id AND field_id_5
          LIKE '%". $param ."%'
          LIMIT 10";
$result = $mysqli->query($query) or die($mysqli->error.__LINE__);

/* Retrieve and store in array the results of the query.*/
while ($row = $result->fetch_assoc()) {

    $row_array['jItemCode']        = $row['field_id_5'];
    $row_array['jItemDesc']        = $row['title'];
    $row_array['jItemPrice']       = $row['field_id_57'];
    //$row_array['jItemWholesale']        = $row['itemWholesale'];
    //$row_array['jItemRetail']           = $row['itemRetail'];
   // $row_array['jQtyOnHand']            = $row['qtyOnHand'];

    array_push( $return_arr, $row_array );
}


$result->free_result();
$mysqli->close();

/* Toss back results as json encoded array. */
echo json_encode($return_arr);

我在电子邮件中得到的只是“我们已收到以下信息: 代码: 说明: 价格: "


请有人帮我一下。我哪里做错了。我知道我很接近,问题在于引用表单中的数据数组。

从代码中很难说,但主要原因是$\u REQUEST[$a]是空的。因此,请在提交表单后立即尝试回显整个$\u请求,以便更好地进行调试


另外,我没有看到提交按钮和表单标签的结尾-这也可能是bug。

$\u请求[$a]
?我不是PHP专家,但这看起来不对。如果我错了,请纠正我。您只显示“代码、描述、价格”的原因是因为这是您在循环中唯一要做的事情。您只是在“fields”数组中循环,而不是在每个$u POST请求中循环。
    <?php 
 $headers  = 'MIME-Version: 1.0' . "\r\n";
 $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
 $headers .= "From: " . $_REQUEST['repName'] . ">\r\n";

 $to = 'dominic.mcafee@pmcnttyyre.com'; 
 $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: noreply@example.com"; 
 $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"; 
    } 
?>