if($action == 'post')
{
if(empty($do))
{
$postform = $diy->getForm(true);
include DEDEROOT."/templets/plus/{$diy->postTemplate}";
exit();
}
elseif($do == 2)
{
$dede_fields = empty($dede_fields) ? '' : trim($dede_fields);
$dede_fieldshash = empty($dede_fieldshash) ? '' : trim($dede_fieldshash);
if(!empty($dede_fields))
{
if($dede_fieldshash != md5($dede_fields.$cfg_cookie_encode))
{
showMsg('数据校验不对,程序返回', '-1');
exit();
}
}
$diyform = $dsql->getOne("select * from where diyid='$diyid' ");
if(!is_array($diyform))
{
showmsg('自定义表单不存在', '-1');
exit();
}
$addvar = $addvalue = '';
if(!empty($dede_fields))
{
$fieldarr = explode(';', $dede_fields);
if(is_array($fieldarr))
{
foreach($fieldarr as $field)
{
if($field == '') continue;
$fieldinfo = explode(',', $field);
if($fieldinfo[1] == 'textdata')
{
${$fieldinfo[0]} = FilterSearch(stripslashes(${$fieldinfo[0]}));
${$fieldinfo[0]} = addslashes(${$fieldinfo[0]});
}
else
{
${$fieldinfo[0]} = GetFieldValue(${$fieldinfo[0]}, $fieldinfo[1],0,'add','','diy', $fieldinfo[0]);
}
$addvar .= ', `'.$fieldinfo[0].'`';
$addvalue .= ", '".${$fieldinfo[0]}."'";
}
}
}
$query = "insert into `{$diy->table}` (`id`, `ifcheck` $addvar) values (NULL, 0 $addvalue); ";
if($dsql->executenonequery($query))
{
$id = $dsql->GetLastID();
if($diy->public == 2)
{
//diy.php?action=view&diyid={$diy->diyid}&id=$id
$goto = "diy.php?action=list&diyid={$diy->diyid}";
$bkmsg = '发布成功,现在转向表单列表页...';
}
else
{
$goto = !empty($cfg_cmspath) ? $cfg_cmspath : '/';
$bkmsg = '发布成功,请等待管理员处理...';
}
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>订单核对 </title>
<link href=http://www.dede58.com/"/img_cnosn/css_end.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="ctent">
<h1>您已成功提交订单,请仔细核对你的信息!</h1>
<ul>
<script language="javascript">
function ReplaceAll(str,sptr,sptr1)
{
while (str.indexOf(sptr) >= 0)
{
str = str.replace(sptr, sptr1);
}
return str;
}
descria=",您的姓名:,联系电话:,送货地址:,购买产品:,支付方式:,订货留言:,b";
var descri=new Array();
descri=descria.split(",");
str= "'.$addvalue.'" ;
str=ReplaceAll(str,"\'","");
var strarray=new Array();
strarray=str.split(",") ;
for(i=0;i<7;i++){
document.write("<li>"+descri[i]+strarray[i]+"</li>");
}
</script>
</ul>
<div class="info">友情提示:您的订单已提交成功,我们的客服会尽快与你取得联系 <a href="#" onclick="window.operner = null;window.open(\'\',\'_self\');window.close();">确认并关闭</a> 或 <a href="#" onclick="window.operner = null;window.open(\'\',\'_self\');window.close();">返回修改</a></div>
</div>
</body>
</html>
';
}
}
}
上是代码。这样就是固定提取前几个表单信息给用户确认,不过在后台增加表单的时候一定要统一按以上数组的顺序进行添加字段。这样才能对应。
有一个不好的地方是,这个文件只要一改就是针对所有的表单提交,不过这只是一个方法,供参考,最终还得灵活应用。