在上一篇《织梦自定义表单提示数据校验不对的解决办法》织梦教程中,解决了DeDeCMS的表单问题,这篇织梦教程将是解决DeDeBIZ的表单问题。废话少说,直接上教程吧。
教程开始
1、打开 /apps/diy.php 搜索
$diy = new diyform($diyid);
在它后面敲个回车,然后在它下面加入
$dede_fields = $diy->getForm2(true);
2、继续往下看到下面这段代码,大概在 30 ~ 35 行左右
if (!empty($dede_fields)) { if ($dede_fieldshash != md5($dede_fields.$cfg_cookie_encode)) { showMsg('数据校验不对', '-1'); exit(); } }
把它们注释或者删掉,以后就不会提示数据校验不对了。
添加方法
打开 /system/diyform.cls.php 搜索 大概在 63 行左右
getForm(
然后看到 84 ~ 87行左右,看到下面的代码
$formstring .= "<input type=\"hidden\" name=\"dede_fields\" value=\"".$formfields."\" />\n"; $formstring .= "<input type=\"hidden\" name=\"dede_fieldshash\" value=\"".md5($formfields.$cfg_cookie_encode)."\" />"; return $formstring; }
把它们改为
//$formstring .= "<input type=\"hidden\" name=\"dede_fields\" value=\"".$formfields."\" />\n"; //$formstring .= "<input type=\"hidden\" name=\"dede_fieldshash\" value=\"".md5($formfields.$cfg_cookie_encode)."\" />"; return $formstring; } function getForm2($type = 'post', $value = '', $admintype = 'diy') { $dtp = new DedeTagParse(); $dtp->SetNameSpace("field", "<", ">"); $dtp->LoadSource($this->info); $formstring = ''; $formfields = ''; $func = $type == 'post' ? 'GetFormItem' : 'GetFormItemValue'; if (is_array($dtp->CTags)) { foreach ($dtp->CTags as $tagid => $tag) { if ($tag->GetAtt('autofield')) { if ($type == 'post') { $formstring .= $func($tag, $admintype); } else { $formstring .= $func($tag, dede_htmlspecialchars($value[$tag->GetName()], ENT_QUOTES), $admintype); } $formfields .= $formfields == '' ? $tag->GetName().','.$tag->GetAtt('type') : ';'.$tag->GetName().','.$tag->GetAtt('type'); } } } $aformfields .= $formfields; return $aformfields; }
之前,加了 getForm2() 方法,补上这段代码,就不会报错了。
调用标签
可参考《织梦自定义表单提示数据校验不对的解决办法》中的DeDeCMS教程。
+33 33 个回复 | 最后更新于 2025-01-16
登录后方可回帖