2013-03-26 82 views
0

我写了一个大约一年前的订单形式的应用程序,这将允许用户选择一些项目,然后点击提交按钮提交按钮,然后触发一个PHP脚本,为该人创建一个电子邮件发票谁命令它和公司谁是suppy产品。PHP电子邮件生成文件错误

现在我对PHP仍然很陌生,现在我已经回到它了我已经忘记了我写的很多东西,出于某种原因,我在我的电子邮件中收到错误,希望有人能帮我找到。

这是我的订单页面的样子

enter image description here

这是该页面

<p><i>Required fields are marked with</i> <b>*</b></p> 

<form action="orderformDNP.php" method="post" 
onsubmit="document.getElementById('myButton').disabled=true; 
document.getElementById('myButton').value='Submitting...';" 
> 

<table width="496" border="0" style="border-width: 1px; border-color:#E5E5E5; 
border-style: solid;"> 
    <tr> 
     <td width="40%"> 
      Name: * 
     </td> 
     <td width="60%"> 
      <input type="text" name="yourname" /> 
     </td> 
    </tr> 
    <tr> 
     <td width="40%"> 
      Phone Number: * 
     </td> 
     <td width="60%"> 
      <input type="text" name="phonenumber" /> 
     </td> 
    </tr> 
    <tr> 
     <td width="40%"> 
      Mobile Number: 
     </td> 
     <td width="60%"> 
      <input type="text" name="mobilenumber" /> 
     </td> 
    </tr> 
    <tr> 
     <td width="40%"> 
      E-mail: * 
     </td> 
     <td width="60%"> 
      <input type="text" name="email" /> 
     </td> 
    </tr> 
    <tr> 
     <td width="40%"> 
      Deliver Address: * 
     </td> 
     <td width="60%"> 
      <textarea name="deliveryaddress" rows="3" cols="40"></textarea> 
     </td> 
    </tr> 
</table> 
</br> 


<!-- this is the ordering part of the form --!> 

<h3>Duvets</h3> 

<?php 

//Start session 
    //session_start(); 

    //Include database connection details 
    require_once('config.php'); 

    //Array to store validation errors 
    $errmsg_arr = array(); 

    //Validation error flag 
    $errflag = false; 

    //Connect to mysql server 
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); 
    if(!$link) { 
     die('Failed to connect to server: ' . mysql_error()); 
    } 

    //Select database 
    $db = mysql_select_db(DB_DATABASE); 
    if(!$db) { 
     die("Unable to select database"); 
    } 



$result = mysql_query("SELECT * FROM 5050goosedown ORDER BY price ASC"); 

echo "<table border='0' width='496'> 
<tr> 
<th width='30%'><b>50/50 Goose Down:</b></th> 
<th width='30%'><i>Normal Fill/Our Fill</i></th> 
<th width='12.5%'><i>Old Price</i></th> 
<th width='12.5%'><i>Price</i></th> 
<th width='12.5%'><i>Quantity</i></th> 
</tr>"; 

$i = 1; 
while($row = mysql_fetch_array($result)){ 
    echo "<tr bgcolor='#F5F5F5'>"; 
    if($i%2 == 0){ 
     echo "<tr bgcolor='#E5E5E5'>"; 
    } 
    $i++; 

    if (($row['width'] ==0) && ($row['height']== 0)){ 
    echo "<td>" . $row['name'] . "</td>"; 
    } 
    else { 
    echo "<td>" . $row['name'] . " -" . $row['width'] . "/" . $row['height'] . "</td>"; 
    } 
    echo "<td>" . $row['normal_fill'] . "/" . $row['our_fill'] . "</td>"; 
    if ($row['old_price'] !=0){ 
    echo "<td>" . $row['old_price'] . "</td>"; 
    } 
    else { 
    echo "<td></td>"; 
    } 
    echo "<td>" . $row['price'] . "</td>"; 
    echo "<td><select name=". $row['goosedown_id'] ."> 
       <option value=''> 0 </option> 
       <option>1</option> 
       <option>2</option> 
       <option>3</option> 
       <option>4</option> 
       <option>5</option> 
       <option>6</option> 
       <option>7</option> 
       <option>8</option> 
      </select> 
     </td>"; 
    echo "</tr>"; 
    } 
echo "</table>"; 

?> 
</br></br> 
<?php 

//Start session 
    //session_start(); 

    //Include database connection details 
    require_once('config.php'); 

    //Array to store validation errors 
    $errmsg_arr = array(); 

    //Validation error flag 
    $errflag = false; 

    //Connect to mysql server 
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); 
    if(!$link) { 
     die('Failed to connect to server: ' . mysql_error()); 
    } 

    //Select database 
    $db = mysql_select_db(DB_DATABASE); 
    if(!$db) { 
     die("Unable to select database"); 
    } 


$result = mysql_query("SELECT * FROM 5050duckdown ORDER BY price ASC"); 

echo "<table border='0' width='496'> 
<tr> 
<th width='30%'><b>50/50 Duck Down:</b></th> 
<th width='30%'><i>Normal Fill/Our Fill</i></th> 
<th width='12.5%'><i>Price</i></th> 
<th width='12.5%'><i>Quantity</i></th> 
</tr>"; 

$i = 1; 
while($row = mysql_fetch_array($result)){ 
    echo "<tr bgcolor='#F5F5F5'>"; 
    if($i%2 == 0){ 
     echo "<tr bgcolor='#E5E5E5'>"; 
    } 
    $i++; 

    if (($row['width'] ==0) && ($row['height']== 0)){ 
    echo "<td>" . $row['name'] . "</td>"; 
    } 
    else { 
    echo "<td>" . $row['name'] . " -" . $row['width'] . "/" . $row['height'] . "</td>"; 
    } 
    echo "<td>" . $row['normal_fill'] . "/" . $row['our_fill'] . "</td>"; 
    echo "<td>" . $row['price'] . "</td>"; 
    echo "<td><select name=". $row['duckdown_id'] ."> 
       <option value=''> 0 </option> 
       <option>1</option> 
       <option>2</option> 
       <option>3</option> 
       <option>4</option> 
       <option>5</option> 
       <option>6</option> 
       <option>7</option> 
       <option>8</option> 
      </select> 
     </td>"; 
    echo "</tr>"; 
    } 
echo "</table>"; 

?> 
</br></br> 
<?php 

//Start session 
    //session_start(); 

    //Include database connection details 
    require_once('config.php'); 

    //Array to store validation errors 
    $errmsg_arr = array(); 

    //Validation error flag 
    $errflag = false; 

    //Connect to mysql server 
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); 
    if(!$link) { 
     die('Failed to connect to server: ' . mysql_error()); 
    } 

    //Select database 
    $db = mysql_select_db(DB_DATABASE); 
    if(!$db) { 
     die("Unable to select database"); 
    } 


$result = mysql_query("SELECT * FROM 955goosedown ORDER BY price ASC"); 

echo "<table border='0' width='496'> 
<tr> 
<th width='30%'><b>95/5 Goose Down:</b></th> 
<th width='30%'><i>Normal Fill/Our Fill</i></th> 
<th width='12.5%'><i>Old Price</i></th> 
<th width='12.5%'><i>Price</i></th> 
<th width='12.5%'><i>Quantity</i></th> 
</tr>"; 

$i = 1; 
while($row = mysql_fetch_array($result)){ 
    echo "<tr bgcolor='#F5F5F5'>"; 
    if($i%2 == 0){ 
     echo "<tr bgcolor='#E5E5E5'>"; 
    } 
    $i++; 

    if (($row['width'] ==0) && ($row['height']== 0)){ 
    echo "<td>" . $row['name'] . "</td>"; 
    } 
    else { 
    echo "<td>" . $row['name'] . " -" . $row['width'] . "/" . $row['height'] . "</td>"; 
    } 
    echo "<td>" . $row['normal_fill'] . "/" . $row['our_fill'] . "</td>"; 
    if ($row['old_price'] !=0){ 
    echo "<td>" . $row['old_price'] . "</td>"; 
    } 
    else { 
    echo "<td></td>"; 
    } 
    echo "<td>" . $row['price'] . "</td>"; 
    echo "<td><select name=". $row['955goosedown_id'] ."> 
       <option value=''> 0 </option> 
       <option>1</option> 
       <option>2</option> 
       <option>3</option> 
       <option>4</option> 
       <option>5</option> 
       <option>6</option> 
       <option>7</option> 
       <option>8</option> 
      </select> 
     </td>"; 
    echo "</tr>"; 
    } 
echo "</table>"; 

?> 
</br> 
<h3>Pillows</h3> 

<?php 

//Start session 
    //session_start(); 

    //Include database connection details 
    require_once('config.php'); 

    //Array to store validation errors 
    $errmsg_arr = array(); 

    //Validation error flag 
    $errflag = false; 

    //Connect to mysql server 
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); 
    if(!$link) { 
     die('Failed to connect to server: ' . mysql_error()); 
    } 

    //Select database 
    $db = mysql_select_db(DB_DATABASE); 
    if(!$db) { 
     die("Unable to select database"); 
    } 


$result = mysql_query("SELECT * FROM goosedownpillows ORDER BY price ASC"); 

echo "<table border='0' width='496'> 
<tr> 
<th width='62.5%'><b>Goose Down Pillows:</b></th> 
<th width='12.5%'><i>Price</i></th> 
<th width='12.5%'><i>Quantity</i></th> 
</tr>"; 

$i = 1; 
while($row = mysql_fetch_array($result)){ 
    echo "<tr bgcolor='#F5F5F5'>"; 
    if($i%2 == 0){ 
     echo "<tr bgcolor='#E5E5E5'>"; 
    } 
    $i++; 

    echo "<td>" . $row['name'] ."</td>"; 
    echo "<td>" . $row['price'] . "</td>"; 
    echo "<td><select name=". $row['goosedownpillows_id'] ."> 
       <option value=''> 0 </option> 
       <option>1</option> 
       <option>2</option> 
       <option>3</option> 
       <option>4</option> 
       <option>5</option> 
       <option>6</option> 
       <option>7</option> 
       <option>8</option> 
      </select> 
     </td>"; 
    echo "</tr>"; 
    } 
echo "</table>"; 

?> 
</br> 
<h3>Feather Mattress Toppers</h3> 

<?php 

//Start session 
    //session_start(); 

    //Include database connection details 
    require_once('config.php'); 

    //Array to store validation errors 
    $errmsg_arr = array(); 

    //Validation error flag 
    $errflag = false; 

    //Connect to mysql server 
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); 
    if(!$link) { 
     die('Failed to connect to server: ' . mysql_error()); 
    } 

    //Select database 
    $db = mysql_select_db(DB_DATABASE); 
    if(!$db) { 
     die("Unable to select database"); 
    } 


$result = mysql_query("SELECT * FROM feathermattresstoppers ORDER BY price ASC"); 

echo "<table border='0' width='496'> 
<tr> 
<th width='62.5%'><b>95/5 Mattress Toppers:</b></th> 
<th width='12.5%'><i>Old Price</i></th> 
<th width='12.5%'><i>Price</i></th> 
<th width='12.5%'><i>Quantity</i></th> 
</tr>"; 

$i = 1; 
while($row = mysql_fetch_array($result)){ 
    echo "<tr bgcolor='#F5F5F5'>"; 
    if($i%2 == 0){ 
     echo "<tr bgcolor='#E5E5E5'>"; 
    } 
    $i++; 

    if (($row['width'] ==0) && ($row['height']== 0)){ 
    echo "<td>" . $row['name'] . "</td>"; 
    } 
    else { 
    echo "<td>" . $row['name'] . " -" . $row['width'] . "/" . $row['height'] . "</td>"; 
    } 
    if ($row['old_price'] !=0){ 
    echo "<td>" . $row['old_price'] . "</td>"; 
    } 
    else { 
    echo "<td></td>"; 
    } 
    echo "<td>" . $row['price'] . "</td>"; 
    echo "<td><select name=". $row['feathermattresstoppers_id'] ."> 
       <option value=''> 0 </option> 
       <option>1</option> 
       <option>2</option> 
       <option>3</option> 
       <option>4</option> 
       <option>5</option> 
       <option>6</option> 
       <option>7</option> 
       <option>8</option> 
      </select> 
     </td>"; 
    echo "</tr>"; 
    } 
echo "</table>"; 

?> 





<p><b>Additional Info:</b><br /> 
<textarea name="comments" rows="10" cols="40"></textarea></p> 
</br></br>496 

Access code: <input type="text" name="code" /><br /> 
Please enter <i>MYCODE</i> above. </br></br> 

<input type="submit" value="Submit" id="myButton" /> 

     </td> 

    </tr> 
</table> 

</td> 

这是orderformDNP其剂量似乎没有正常工作的代码..这我只是说不出为什么..

<?php 
    session_start(); 

    $body_items = ''; 
    $total_price = 0; 


    /* Set Redgraves Email address, so they receive the orders */ 
    $myemail = "[email protected]"; 

    /* Check all form inputs using check_input function */ 
    $yourname = check_input($_POST['yourname'], "Enter your name"); 
    $phonenumber = check_input($_POST['phonenumber'], "Enter your phone number"); 
    $mobilenumber = check_input($_POST['mobilenumber']); 
    $email = check_input($_POST['email'], "Enter your E-mail address"); 
    $deliveryaddress = check_input($_POST['deliveryaddress'], "Enter your delivery address"); 

    $comments = check_input($_POST['comments']); 

    $random = substr(number_format(time() * rand(),0,'',''),0,10); 

    $goosedown_id = ($_POST[$row['goosedown_id']]); 




    if (strtolower($_POST['code']) != 'mycode') 
    { 
     die('Wrong access code'); 
    } 

    /* If e-mail is not valid show error message */ 
    if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email)) 
    { 
     show_error("E-mail address not valid"); 
    } 

    /* If phone number has characters show error message */ 
    if (preg_match("/\D/",$phonenumber)) 
    { 
     die("Please enter numbers only for Phone Number"); 
    } 

    /* If mobile number has characters show error message */ 
    if (preg_match("/\D/",$mobilenumber)) 
    { 
     die("Please enter numbers only for Mobile Number"); 
    } 


    // 5050duckdown 
    $flag = 0; 
    $i = 1; 
    $order_content = ''; 
    foreach ($_POST['5050goosedown'] as $key => $value) { 
     if ($value > 0) { 
      $flag = 1; 
      if($i%2 == 0) 
       $order_content .= "<tr bgcolor='#E5E5E5'>"; 
      else 
       $order_content .= "<tr bgcolor='#F5F5F5'>"; 
      $i++; 

      if (($row['width'] ==0) && ($row['height']== 0)) 
       $order_content .= "<td>" . $_SESSION['5050goosedown'][$key]['name'] . "</td>"; 
      else 
       $order_content .= "<td>" . $_SESSION['5050goosedown'][$key]['name'] . " -" . $_SESSION['5050goosedown'][$key]['width'] . "/" . $_SESSION['5050goosedown'][$key]['height'] . "</td>"; 

      $order_content .= "<td>" . $_SESSION['5050goosedown'][$key]['price'] . "</td>"; 

      $order_content .= "<td>" . $value . "</td>"; 

      $sub = $_SESSION['5050goosedown'][$key]['price'] * $value; 
      $total_price += $sub; 
      $order_content .= "<td>" . $sub . "</td></tr>"; 
     } 
    } 

    if ($flag == 1) { 
     $body_items .= "<table border='0' width='600'> 
          <tr> 
           <th width='30%'><b>50/50 Goose Down:</b></th> 
           <th width='12.5%'><i>Item Price</i></th> 
           <th width='12.5%'><i>Quantity</i></th> 
           <th width='12.5%'><i>Price</i></th> 
          </tr>"; 
     $body_items .= $order_content; 
     $body_items .= '</table><br /><br />'; 
    } 

    ////////////// 
    $flag = 0; 
    $i = 1; 
    $order_content = ''; 
    foreach ($_POST['5050duckdown'] as $key => $value) { 
     if ($value > 0) { 
      $flag = 1; 
      if($i%2 == 0) 
       $order_content .= "<tr bgcolor='#E5E5E5'>"; 
      else 
       $order_content .= "<tr bgcolor='#F5F5F5'>"; 
      $i++; 

      if (($row['width'] ==0) && ($row['height']== 0)) 
       $order_content .= "<td>" . $_SESSION['5050duckdown'][$key]['name'] . "</td>"; 
      else 
       $order_content .= "<td>" . $_SESSION['5050duckdown'][$key]['name'] . " -" . $_SESSION['5050duckdown'][$key]['width'] . "/" . $_SESSION['5050duckdown'][$key]['height'] . "</td>"; 

      $order_content .= "<td>" . $_SESSION['5050duckdown'][$key]['price'] . "</td>"; 

      $order_content .= "<td>" . $value . "</td>"; 

      $sub = $_SESSION['5050duckdown'][$key]['price'] * $value; 
      $total_price += $sub; 
      $order_content .= "<td>" . $sub . "</td></tr>"; 
     } 
    } 

    if ($flag == 1) { 
     $body_items .= "<table border='0' width='600'> 
          <tr> 
           <th width='30%'><b>50/50 Duck Down:</b></th> 
           <th width='12.5%'><i>Item Price</i></th> 
           <th width='12.5%'><i>Quantity</i></th> 
           <th width='12.5%'><i>Price</i></th> 
          </tr>"; 
     $body_items .= $order_content; 
     $body_items .= '</table><br /><br />'; 
    } 

    ///////////////// 
    $flag = 0; 
    $i = 1; 
    $order_content = ''; 
    foreach ($_POST['955goosedown'] as $key => $value) { 
     if ($value > 0) { 
      $flag = 1; 
      if($i%2 == 0) 
       $order_content .= "<tr bgcolor='#E5E5E5'>"; 
      else 
       $order_content .= "<tr bgcolor='#F5F5F5'>"; 
      $i++; 

      if (($row['width'] ==0) && ($row['height']== 0)) 
       $order_content .= "<td>" . $_SESSION['955goosedown'][$key]['name'] . "</td>"; 
      else 
       $order_content .= "<td>" . $_SESSION['955goosedown'][$key]['name'] . " -" . $_SESSION['955goosedown'][$key]['width'] . "/" . $_SESSION['955goosedown'][$key]['height'] . "</td>"; 

      $order_content .= "<td>" . $_SESSION['955goosedown'][$key]['price'] . "</td>"; 

      $order_content .= "<td>" . $value . "</td>"; 

      $sub = $_SESSION['955goosedown'][$key]['price'] * $value; 
      $total_price += $sub; 
      $order_content .= "<td>" . $sub . "</td></tr>"; 
     } 
    } 

    if ($flag == 1) { 
     $body_items .= "<table border='0' width='600'> 
          <tr> 
           <th width='30%'><b>95/5 Goose Down:</b></th> 
           <th width='12.5%'><i>Item Price</i></th> 
           <th width='12.5%'><i>Quantity</i></th> 
           <th width='12.5%'><i>Price</i></th> 
          </tr>"; 
     $body_items .= $order_content; 
     $body_items .= '</table><br /><br />'; 
    } 

    ////// 
    $flag = 0; 
    $i = 1; 
    $order_content = ''; 
    foreach ($_POST['goosedownpillows'] as $key => $value) { 
     if ($value > 0) { 
      $flag = 1; 
      if($i%2 == 0) 
       $order_content .= "<tr bgcolor='#E5E5E5'>"; 
      else 
       $order_content .= "<tr bgcolor='#F5F5F5'>"; 
      $i++; 

      if (($row['width'] ==0) && ($row['height']== 0)) 
       $order_content .= "<td>" . $_SESSION['goosedownpillows'][$key]['name'] . "</td>"; 
      else 
       $order_content .= "<td>" . $_SESSION['goosedownpillows'][$key]['name'] . " -" . $_SESSION['goosedownpillows'][$key]['width'] . "/" . $_SESSION['goosedownpillows'][$key]['height'] . "</td>"; 

      $order_content .= "<td>" . $_SESSION['goosedownpillows'][$key]['price'] . "</td>"; 

      $order_content .= "<td>" . $value . "</td>"; 

      $sub = $_SESSION['goosedownpillows'][$key]['price'] * $value; 
      $total_price += $sub; 
      $order_content .= "<td>" . $sub . "</td></tr>"; 
     } 
    } 

    if ($flag == 1) { 
     $body_items .= "<table border='0' width='600'> 
          <tr> 
           <th width='30%'><b>Goose Down Pillows:</b></th> 
           <th width='12.5%'><i>Item Price</i></th> 
           <th width='12.5%'><i>Quantity</i></th> 
           <th width='12.5%'><i>Price</i></th> 
          </tr>"; 
     $body_items .= $order_content; 
     $body_items .= '</table><br /><br />'; 
    } 

    ////// 
    $flag = 0; 
    $i = 1; 
    $order_content = ''; 
    foreach ($_POST['feathermattresstoppers'] as $key => $value) { 
     if ($value > 0) { 
      $flag = 1; 
      if($i%2 == 0) 
       $order_content .= "<tr bgcolor='#E5E5E5'>"; 
      else 
       $order_content .= "<tr bgcolor='#F5F5F5'>"; 
      $i++; 

      if (($row['width'] ==0) && ($row['height']== 0)) 
       $order_content .= "<td>" . $_SESSION['feathermattresstoppers'][$key]['name'] . "</td>"; 
      else 
       $order_content .= "<td>" . $_SESSION['feathermattresstoppers'][$key]['name'] . " -" . $_SESSION['feathermattresstoppers'][$key]['width'] . "/" . $_SESSION['feathermattresstoppers'][$key]['height'] . "</td>"; 

      $order_content .= "<td>" . $_SESSION['feathermattresstoppers'][$key]['price'] . "</td>"; 

      $order_content .= "<td>" . $value . "</td>"; 

      $sub = $_SESSION['feathermattresstoppers'][$key]['price'] * $value; 
      $total_price += $sub; 
      $order_content .= "<td>" . $sub . "</td></tr>"; 
     } 
    } 

    if ($flag = 1) { 
     $body_items .= "<table border='0' width='600'> 
          <tr> 
           <th width='30%'><b>95/5 Mattress Toppers:</b></th> 
           <th width='12.5%'><i>Item Price</i></th> 
           <th width='12.5%'><i>Quantity</i></th> 
           <th width='12.5%'><i>Price</i></th> 
          </tr>"; 
     $body_items .= $order_content; 
     $body_items .= '</table><br /><br />'; 
    } 
    $body_items .= "<br /><b>Total: $total_price</b></b></b>"; 



/*-------------------First Email--------------------*/ 

    /* Set Email for Redgraves, so they can for-full the order form */ 
    $message = "A order form has been submitted by: $yourname<br /><br /> 

    Order number :<u>$random</u><br /><br /> 

    <b>Name:</b> $yourname<br /> 
    <b>E-mail:</b> $email<br /> 
    <b>Phone Number:</b> $phonenumber<br /> 
    <b>Mobile Number:</b> $mobilenumber<br /> 
    <b>Delivery Address:</b> $deliveryaddress<br /> 
    <b>Comments:</b> $comments<br /><br /> 

    $body_items 


    <br /><br />**End of message** 
    "; 

/* Send the message using mail() function */ 
    $header= "MIME-Version: 1.0\r\n"; 
    $header.= "Content-type: text/html\r\n"; 
    mail($myemail, "Order Submitted", $message, $header); 

    /* Send the message using mail() function */ 
    //mail($myemail, "Order Submitted", $message); 

/*---------------Second Email---------------------*/  

    /* This email is to confirm the order and act as a receipt to the purchaser */ 
    $respond_message = "Order Completed<br /><br /> 

    Your order has been submitted! details are as follows<br /><br /> 

    <b>Name:</b> $yourname<br /> 
    <b>E-mail:</b> $email<br /> 
    <b>Phone Number:</b> $phonenumber<br /> 
    <b>Mobile Number:</b> $mobilenumber<br /> 
    <b>Delivery Address:</b> $deliveryaddress<br /> 
    <b>Comments:</b> $comments<br /><br /> 

    $body_items 


    <br /><b>Reference Number:</b> <u>$random</u><br /><br /> 

    Please make payment using the refrence number above within 7 working days or your order will be canceled <br /> 
    ASB 000-0000-0000-00 "; 

    /* Send the message using mail() function */ 
    $headers= "MIME-Version: 1.0\r\n"; 
    $headers.= "Content-type: text/html\r\n"; 
    mail($email, "Thank you for your order", $respond_message, $headers); 


    /* Redirect visitor to the thank you page */ 
    header('Location: thankyou.html'); 
exit(); 




/* Functions we used */ 
function check_input($data, $problem='') 
{ 
    $data = trim($data); 
    $data = stripslashes($data); 
    $data = htmlspecialchars($data); 
    if ($problem && strlen($data) == 0) 
    { 
     show_error($problem); 
    } 
    return $data; 
} 




function show_error($myError) 
{ 
?> 
    <html> 
    <body> 

    <b>Please correct the following error:</b><br /> 
    <?php echo $myError; ?> 

    </body> 
    </html> 
<?php 
exit(); 
} 
?> 

这是发生了什么事到电子邮件... :(

A order form has been submitted by: kc 

Order number :8674170468 

Name: kc 
E-mail: [email protected] 
Phone Number: 0941 
Mobile Number: 64215 
Delivery Address: japan 
Comments: 

95/5 Mattress Toppers: Item Price Quantity Price 



Total: 0 

**End of message** 

我一直在此为一对夫妇,现在两天,我woundering也许可以在此错误可以通过在数据库什么的PHP版本引起的???

任何帮助,将不胜感激

UPDATE:这是从的print_r($ _ POST)生成的;

Array ([yourname] => kc 
     [phonenumber] => 987 
     [mobilenumber] => 987 
     [email] => [email protected] 
     [deliveryaddress] => testing 66 
     [1] => 
     [2] => 
     [comments] => sdsdf 
     [code] => MYCODE) 

更新2:电子邮件输出不ouputting价格,以及一对夫妇的其他值

enter image description here

+1

'总数:0'这是错误的一部分吗? – 2013-03-26 07:00:37

+1

看不到任何错误 – 2013-03-26 07:01:24

+0

@HankyPankyㇱ是的,无论我在第一部分中选择多少项目,alwas返回0作为我现在的总数..并且总是95/5床垫Toppers,即使没有选定的值面积 – HurkNburkS 2013-03-26 07:04:44

回答

2

if ($flag = 1)

也许应该if ($flag == 1)

它的正确写入后者适用于大多数条件,但不适用于亚光的顶头人之一。这就是为什么空床垫顶部总是出现。

根据$_POST中显示的内容,看起来您的实际表单字段的名称与您期望找到的名称之间存在不匹配。例如,50/50 Goosedown部分正在寻找:$_POST['5050goosedown'],但我认为与此相关的下拉列表是<select name=". $row['goosedown_id'] .">,所以它将显示在$ _POST中,并且其键值等于$row['goosedown_id']。它看起来像这些数字(在$_POST12空值条目。

他们为什么是空的?我的猜测是,这些ID在多个领域共享,所以你有多个同名的选择他们在提交时与彼此冲突。

尝试改变选择看起来像这样(例如用于第一个):

echo '<td><select name="5050goosedown[' . $row['goosedown_id'] . ']">' 
. "<option>1</option> 
<option>2</option> 
and so on 

这将导致其在$_POST显示为一个嵌套阵列例如

array(
    [5050goosedown] => array( 
     [1] => 2, 
     [2] => 
    ) 
) 

这里的特定项目ID是1和2.这似乎是PHP代码所期待的。

+0

好吧,所以我改变了这一点,它采取了这一行“95/5床垫顶级:项目价格数量价格”,但总数仍然等于0 ... :( – HurkNburkS 2013-03-26 07:09:06

+0

'print_r($ _ POST);'和编辑 – FoolishSeth 2013-03-26 07:09:59

+0

我在哪里可以输入那句话对不起? – HurkNburkS 2013-03-26 07:10:54