本文介绍了PHP电子邮件生成文件错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我大约一年前写了一个订单表单应用程序,它允许用户选择一些项目,然后点击提交按钮提交按钮,然后触发一个php脚本,为订购它的人和创建电子邮件发票公司谁suppy产品。



现在我仍然是PHP的新手,现在我已经回到它,我已经忘记了我写的很多,原因我在我的电子邮件中收到一个错误,我希望有人能帮我找到。



这就是我的订单页面看起来像





这是该页面的代码

 < p>< i>必填字段标有< / i> ; < b取代; *< / B>< / p为H. 

< form action =orderformDNP.phpmethod =post
onsubmit =document.getElementById('myButton')。disabled = true;
document.getElementById ( '为myButton')值= '提交...';
>

< table width =496border =0style =border-width:1px; border-color:#E5E5E5;
border-style:solid;>
< tr>
< td width =40%>
名称:*
< / td>
< td width =60%>
< input type =textname =yourname/>
< / td>
< / tr>
< tr>
< td width =40%>
电话号码:*
< / td>
< td width =60%>
< input type =textname =phonenumber/>
< / td>
< / tr>
< tr>
< td width =40%>
手机号码:
< / td>
< td width =60%>
< input type =textname =mobilenumber/>
< / td>
< / tr>
< tr>
< td width =40%>
电子邮件:*
< / td>
< td width =60%>
< input type =textname =email/>
< / td>
< / tr>
< tr>
< td width =40%>
交付地址:*
< / td>
< td width =60%>
< textarea name =deliveryaddressrows =3cols =40>< / textarea>
< / td>
< / tr>
< / table>
< / br>



< h3> Duvets< / h3>

<?php

//开始会话
// session_start();

//包含数据库连接的详细信息
require_once('config.php');

//存储验证错误的数组$ b $ errmsg_arr = array();

//验证错误标志
$ errflag = false;

//连接到mysql服务器
$ link = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);
if(!$ link){
die('无法连接到服务器:'。mysql_error());
}

//选择数据库
$ db = mysql_select_db(DB_DATABASE);
if(!$ db){
die(无法选择数据库);



$ b $ 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>正常填充/我们的填充< / i>< /> ;
< th width = '12.5%>< i>旧价格< i>< Price< / th>>
< th width ='12.5%>< i>数量< / i>< / th>
< / tr>

$ i = 1;
while($ row = mysql_fetch_array($ result)){
echo< tr bgcolor ='#F5F5F5'>;
if($ i%2 == 0){
echo< tr bgcolor ='#E5E5E5'>;
}
$ i ++; ($ row ['width'] == 0)&&($ row ['height'] == 0)){
echo< td>

。 。 $ row ['name']。 < / TD> 中;
}
else {
echo< td> 。 $ row ['name']。 - 。 $ row ['width']。 /。 $ row ['height']。 < / TD> 中;
}
回显< td> 。 $ row ['normal_fill']。 /。 $ row ['our_fill']。 < / TD> 中;
if($ row ['old_price']!= 0){
echo< td> 。 $ row ['old_price']。 < / TD> 中;
}
else {
echo< td>< / td>;
}
回显< td> 。 $ row ['price']。 < / TD> 中;
回显< td>< select name =。 $ row ['goedown_id']。>
< option value =''> 0< / option>
< option> 1< / option>
< option> ; 2< / option>
<选项> 3< / option>
<选项> 4< / option>
< ;选项> 6< / option>
< /选择> 7< / option>
<选项> 8< / option>
< TD>中;
回声< / tr>;
}
echo< / table>;

?>
< / br>< / br>

//开始会话
// session_start();

//包含数据库连接的详细信息
require_once('config.php');

//存储验证错误的数组$ b $ errmsg_arr = array();

//验证错误标志
$ errflag = false;

//连接到mysql服务器
$ link = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);
if(!$ link){
die('无法连接到服务器:'。mysql_error());
}

//选择数据库
$ db = mysql_select_db(DB_DATABASE);
if(!$ db){
die(无法选择数据库);



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

echo'< table border ='0'width ='496'>
< tr>
< th width = '30%'>< < / b>< / th>
< th width = '30%>>< i>普通填充/我们的填充< / i>< / th> ;
< th width = '12 .5%'>< i>价格< i>< th>< th>< i>< i> ; / i>< / th>
< / tr>;

$ i = 1;
while($ row = mysql_fetch_array($ result)){
echo< tr bgcolor ='#F5F5F5'>;
if($ i%2 == 0){
echo< tr bgcolor ='#E5E5E5'>;
}
$ i ++; ($ row ['width'] == 0)&&($ row ['height'] == 0)){
echo< td>

。 。 $ row ['name']。 < / TD> 中;
}
else {
echo< td> 。 $ row ['name']。 - 。 $ row ['width']。 /。 $ row ['height']。 < / TD> 中;
}
回显< td> 。 $ row ['normal_fill']。 /。 $ row ['our_fill']。 < / TD> 中;
回显< td> 。 $ row ['price']。 < / TD> 中;
回显< td>< select name =。 $ row ['duckdown_id']。>
< option value =''> 0< / option>
< option> 1< / option>
< option> ; 2< / option>
<选项> 3< / option>
<选项> 4< / option>
< ;选项> 6< / option>
< /选择> 7< / option>
<选项> 8< / option>
< TD>中;
回声< / tr>;
}
echo< / table>;

?>
< / br>< / br>

//开始会话
// session_start();

//包含数据库连接的详细信息
require_once('config.php');

//存储验证错误的数组$ b $ errmsg_arr = array();

//验证错误标志
$ errflag = false;

//连接到mysql服务器
$ link = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);
if(!$ link){
die('无法连接到服务器:'。mysql_error());
}

//选择数据库
$ db = mysql_select_db(DB_DATABASE);
if(!$ db){
die(无法选择数据库);


$ b $ 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>正常填充/我们填充< / i>< /> ;
< th width = '12.5%>< i>旧价格< i>< Price< / th>>
< th width ='12.5%>< i>数量< / i>< / th>
< / tr>

$ i = 1;
while($ row = mysql_fetch_array($ result)){
echo< tr bgcolor ='#F5F5F5'>;
if($ i%2 == 0){
echo< tr bgcolor ='#E5E5E5'>;
}
$ i ++; ($ row ['width'] == 0)&&($ row ['height'] == 0)){
echo< td>

。 。 $ row ['name']。 < / TD> 中;
}
else {
echo< td> 。 $ row ['name']。 - 。 $ row ['width']。 /。 $ row ['height']。 < / TD> 中;
}
回显< td> 。 $ row ['normal_fill']。 /。 $ row ['our_fill']。 < / TD> 中;
if($ row ['old_price']!= 0){
echo< td> 。 $ row ['old_price']。 < / TD> 中;
}
else {
echo< td>< / td>;
}
回显< td> 。 $ row ['price']。 < / TD> 中;
回显< td>< select name =。 $ row $'
< / option>
< ; 2< / option>
<选项> 3< / option>
<选项> 4< / option>
< ;选项> 6< / option>
< /选择> 7< / option>
<选项> 8< / option>
< TD>中;
回声< / tr>;
}
echo< / table>;

?>
< / br>
< h3>枕头< / h3>

<?php

//开始会话
// session_start();

//包含数据库连接的详细信息
require_once('config.php');

//存储验证错误的数组$ b $ errmsg_arr = array();

//验证错误标志
$ errflag = false;

//连接到mysql服务器
$ link = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);
if(!$ link){
die('无法连接到服务器:'。mysql_error());
}

//选择数据库
$ db = mysql_select_db(DB_DATABASE);
if(!$ db){
die(无法选择数据库);


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

echo'< table border ='0'width ='496'>
< tr>
< th width = '62 .5%'>< b>鹅绒枕头:< / b>< / th>
< th width = '12 .5%>< i>价格< / i>< ; th width = '12.5%'>< i>数量< / i>< / th>
< / tr>;

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

回显< td> 。 $ row ['name']。< / td>;
回显< td> 。 $ row ['price']。 < / TD> 中;
回显< td>< select name =。 $ row $'
< / option>
< ; 2< / option>
<选项> 3< / option>
<选项> 4< / option>
< ;选项> 6< / option>
< /选择> 7< / option>
<选项> 8< / option>
< TD>中;
回声< / tr>;
}
echo< / table>;

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

<?php

//开始会话
// session_start();

//包含数据库连接的详细信息
require_once('config.php');

//存储验证错误的数组$ b $ errmsg_arr = array();

//验证错误标志
$ errflag = false;

//连接到mysql服务器
$ link = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);
if(!$ link){
die('无法连接到服务器:'。mysql_error());
}

//选择数据库
$ db = mysql_select_db(DB_DATABASE);
if(!$ db){
die(无法选择数据库);


$ b $ 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>旧价格< / i>< / th>
< th width ='12.5%>< i>价格< i>< i>< i>< i>< i>< i> ;< / th>
< / tr>;

$ i = 1;
while($ row = mysql_fetch_array($ result)){
echo< tr bgcolor ='#F5F5F5'>;
if($ i%2 == 0){
echo< tr bgcolor ='#E5E5E5'>;
}
$ i ++; ($ 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>;
}
回显< td> 。 $ row ['price']。 < / TD> 中;
回显< td>< select name =。 $ row {'feathermattresstoppers_id']。>
< option value =''> 0< / option>
< option> 1< / option>
< option> ; 2< / option>
<选项> 3< / option>
<选项> 4< / option>
< ;选项> 6< / option>
< /选择> 7< / option>
<选项> 8< / option>
< TD>中;
回声< / tr>;
}
echo< / table>;

?>





< p>< b>附加信息:< / b>< br />
< textarea name =commentsrows =10cols =40>< / textarea>< / p>
< / br>< / br> 496

存取码:< input type =textname =code/>< br />
请输入< i> MYCODE< / i>以上。 < / BR>< / BR>

< input type =submitvalue =Submitid =myButton/>

< / td>

< / tr>
< / table>

< / td>

这是orderformDNP,它似乎没有正常工作..我无法说出原因。

 <?php 
session_start();

$ body_items ='';
$ total_price = 0;


/ *设置Redgraves电子邮件地址,以便他们收到订单* /
$ myemail [email protected];
$ b $ *使用check_input函数检查所有表单输入* /
$ yourname = check_input($ _ POST ['yourname'],Enter your name);
$ phonenumber = check_input($ _ POST ['phonenumber'],输入您的电话号码);
$ mobilenumber = check_input($ _ POST ['mobilenumber']);
$ email = check_input($ _ POST ['email'],输入您的电子邮件地址);
$ deliveryaddress = check_input($ _ POST ['deliveryaddress'],输入您的送货地址);

$ 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('错误的访问代码');

$ b $ *如果电子邮件无效显示错误信息* /
if(!preg_match(/([\ w \ - - ] + \ @ [\ w\ - ] + \。[\w\ - - ] +)/,$ email))
{
show_error(电子邮件地址无效) ;

$ b $ *如果电话号码有字符显示错误信息* /
if(preg_match(/ \D /,$ phonenumber))
{
die(请只输入电话号码的号码);
}
$ b $ *如果手机号码有字符显示错误信息* /
if(preg_match(/ \D /,$ mobilenumber))
{
die(请仅输入手机号码的号码);
}


// 5050duckdown
$ flag = 0;
$ i = 1;
$ order_content =''; ($ value> 0){
$ flag = 1;
foreach($ _POST ['5050goosedown']
if($ i%2 == 0)
$ order_content。=< tr bgcolor ='#E5E5E5'>;
else
$ order_content。=< tr bgcolor ='#F5F5F5'>;
$ i ++; ($ 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> 。 $值。 < / 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>
< < i>< i>< i>< i>< i>< i>< i>< i>< i>< / th>
< th width = '12 .5%'>< i>价格< / i>< / th>
< / tr>
$ body_items。= $ order_content;
$ body_items。='< / table>< br />< br />';
}

//////////////
$ flag = 0;
$ i = 1;
$ order_content =''; ($ value> 0){
$ flag = 1;
foreach($ _POST ['5050duckdown']
if($ i%2 == 0)
$ order_content。=< tr bgcolor ='#E5E5E5'>;
else
$ order_content。=< tr bgcolor ='#F5F5F5'>;
$ i ++; ($ 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> 。 $值。 < / 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停顿:< / b>< / th>
< < i>< i>< i>< i>< i>< i>< i>< i>< i>< / th>
< th width = '12 .5%'>< i>价格< / i>< / th>
< / tr>
$ body_items。= $ order_content;
$ body_items。='< / table>< br />< br />';
}

/////////////////
$ flag = 0;
$ i = 1;
$ order_content =''; ($ value> 0){
$ flag = 1;
foreach($ _POST ['955goosedown']
if($ i%2 == 0)
$ order_content。=< tr bgcolor ='#E5E5E5'>;
else
$ order_content。=< tr bgcolor ='#F5F5F5'>;
$ i ++; ($ 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> 。 $值。 < / 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>
< < i>< i>< i>< i>< i>< i>< i>< i>< i>< / th>
< th width = '12 .5%'>< i>价格< / i>< / th>
< / tr>
$ body_items。= $ order_content;
$ body_items。='< / table>< br />< br />';
}

//////
$ flag = 0;
$ i = 1;
$ order_content =''; ($ value> 0){
$ flag = 1;
foreach($ _POST ['goosedownpillows']
if($ i%2 == 0)
$ order_content。=< tr bgcolor ='#E5E5E5'>;
else
$ order_content。=< tr bgcolor ='#F5F5F5'>;
$ i ++; ($ 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> 。 $值。 < / 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 th th width = '12.5%'>< i>< i>< i>< i>< i>< i>< i>< i>< i>< i>< i>< i>< ;
< 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 ++; ($ 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> 。 $值。 < / 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宽度= '12 0.5% '>< I>项目价格< / I>< /第>
将第宽度= '12 0.5%' >< I>数量< / I>< / < i>
< th width = '12 .5%'>< i> Price< / th>
< / tr>
$ body_items。= $ order_content;
$ body_items。='< / table>< br />< br />';
}
$ body_items。=< br />< b>总计:$ total_price< / b>< / b>< / b>;



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

/ *为Redgraves设置电子邮件,以便他们可以填写订单表单* /
$ message =订单已经存在提交者:$ yourname< br />< br />

订单号:< u> $ random< / u>< br />< br />

< b>名称:< / b> $ yourname< b />
< b>电子邮件:< / b> $ email< br />
将b取代;电话号码:其中/ b个$ PHONENUMBER<峰; br />
将b取代;手机号码:其中/ b个$移动电话号码<峰; br />
将; b>收件地址:< / b> $ deliveryaddress< br />
< b>评论:< / b> $ comments< br />< br />

$ body_items


< br />< br /> **信息结束**
;
$ b $ *使用mail()函数发送邮件* /
$ header =MIME-Version:1.0 \r\\\
;
$ header。=Content-type:text / html\r\\\
;
mail($ myemail,Order Submitted,$ message,$ header);
$ b $ *使用mail()函数* /
// mail($ myemail,Order Submitted,$ message)发送邮件;

/ * ---------------第二封电子邮件--------------------- * /

/ *此电子邮件用于确认订单并作为收据发送给购买者* /
$ respond_message =订单已完成< br />< br />

您的订单已提交!详情如下< br />< br />

< b>名称:< / b> $ yourname< br />
< b>电子邮件:< / b> $电子邮件< BR />
< b>电话号码:其中/ b> $ PHONENUMBER< BR />
将b取代;手机号码:其中/ b个$移动电话号码<峰; br />
将b取代;收货地址:其中/ b个$是DeliveryAddress<峰; br />
< b>评论:< / b> $ comments< br />< br />

$ body_items


< br / >< b>参考编号:< / b>< u> $随机< / u>< br />< br />

请使用参考以上号码在7个工作日内或您的订单将被取消< br / >
ASB 000-0000-0000-00;

/ *使用mail()函数发送消息* /
$ headers =MIME-Version:1.0 \r \ n;
$ headers。=Content-type:text / html\r\\\
;
mail($ email,Thank you for your order,$ respond_message,$头文件);


/ *将访问者重定向到感谢页面* /
header('Location:thankyou.html');
exit();




/ *我们使用的函数* /
函数check_input($ data,$ problem ='')
{
$ data = trim($ data);
$ data = stripslashes($ data);
$ data = htmlspecialchars($ data);
if($ problem&& strlen( $ data)== 0)
{
show_error($ problem);
}
return $ data;
}




函数show_error($ myError)
{
?>
< html>
< body>

< b>请更正以下错误:< / b>< br />
<?php echo $ myError;?>

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

这就是发生在电子邮件中的情况...... :(

 订单已提交:kc 

订单编号:8674170468

名称:kc
电子邮件:[email protected]
电话号码:0941
手机号码:64215
收货地址:japan
评论:

95 / 5床垫Toppers:商品价格数量价格



总计:0

**消息结束**

我已经在这里待了好几天了,可能这个错误可能是由数据库上的php版本引起的,或者东西???



任何帮助将不胜感激



更新:这是从 print_r($ _ POST);

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

更新2:电子邮件输出不会输出价格以及其他几个值 p>

解决方案

if ($flag = 1)



should probably be if ($flag == 1)



It's written correctly as the latter for most of the conditionals but not the mattress toppers one. This is why the empty mattress toppers section always appears.



Based on what’s showing up in $_POST it looks like there is a mismatch between the names of your actual form fields and the names your PHP is expecting to find. For instance the 50/50 Goosedown section is looking for: $_POST[’5050goosedown’] but the dropdown I assume is associated with this is <select name=\". $row[’goosedown_id’] .\"> so it would show up in $_POST with a key equal to whatever $row[’goosedown_id’] is. It looks like these are numbers (the empty-valued entries in $_POST for 1 and 2.



Why are they empty? My guess would be these IDs are shared across more than one field so you have multiple selects with the same name and they’re conflicting with eachother when submitted.



Try changing the selects to look like this (example for the first one):

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

This will cause it to show up in $_POST as a nested array e.g.

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

with the specific item IDs here being 1 and 2. This seems to be what the PHP code is expecting.


I wrote a little order form application about a year ago which would allow a user to select a few items then click submit button the submit button then fires a php script which creates an email invoice for both the person who orders it and the company who is suppy the product.

Now I am still very new to PHP and now that I have come back to it I have forgotten alot of what I wrote and for some reason I am getting an error in my email which I am hoping someone can help me find.

This is what my order form page looks like

This is the code for that page

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

this is orderformDNP which dose not seem to be working correctly.. which I just cannot tell why..

<?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();
}
?>

this is what is happening to the email... :(

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**

I have been on this for a couple of days now and am woundering maybe can this error be caused by php versions on the Data base or something???

any help would be greatly appreciated

UPDATE: this is what is generated from print_r($_POST);

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

Update 2: email output not ouputting price as well as a couple of the other values

解决方案

if ($flag = 1)

should probably be if ($flag == 1)

It's written correctly as the latter for most of the conditionals but not the mattress toppers one. This is why the empty mattress toppers section always appears.

Based on what's showing up in $_POST it looks like there is a mismatch between the names of your actual form fields and the names your PHP is expecting to find. For instance the 50/50 Goosedown section is looking for: $_POST['5050goosedown'] but the dropdown I assume is associated with this is <select name=". $row['goosedown_id'] ."> so it would show up in $_POST with a key equal to whatever $row['goosedown_id'] is. It looks like these are numbers (the empty-valued entries in $_POST for 1 and 2.

Why are they empty? My guess would be these IDs are shared across more than one field so you have multiple selects with the same name and they're conflicting with eachother when submitted.

Try changing the selects to look like this (example for the first one):

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

This will cause it to show up in $_POST as a nested array e.g.

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

with the specific item IDs here being 1 and 2. This seems to be what the PHP code is expecting.

这篇关于PHP电子邮件生成文件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 19:03