在帝国cms建站中可以会用到系统自带的留言板功能。而系统自带的字段比较少,我们可以自己适当增加一些字段来作为必填项。需要几个就增加几个,爱折腾的摄影大叔整理了一下具体方法。
具体操作步骤如下:
第一步:.在数据库(如下图)的前缀名***_enewsgbook表中添加需要显示的字段内容,比如我要加爱好"like"字段。
方法1:可以用工具在***_enewsgbook中添加,
方法2:可以执行sql语句添加:ALTER TABLE 前缀名***_enewsgbook ADD like VARCHAR(100);
第二部:修改e/enews/gbookfun.php
第17行左右:
$name=RepPostStr(trim($add[name])); $email=RepPostStr($add[email]); $call=RepPostStr($add[call]); $lytext=RepPostStr($add[lytext]); $gtitle=RepPostStr(trim($add[like])); //增加的like if(empty($bid)||empty($like)||empty($name)||empty($email)||!trim($lytext)) //like字段检测不允许为空第56行左右:
$sql=$empire->query("insert into {$dbtbpre}enewsgbook(name,gtitle,email,`call`,lytime,lytext,retext,bid,ip,checked,userid,username) values('$name','$like','$email','$call','$lytime','$lytext','','$bid','$ip','$br[checked]','$userid','$username');"); //插入字段记录第三步:修改e/data/template/gbooktemp.txt
第50行左右:
$query="select lyid,name,like,email,`call`,lytime,lytext,retext from {$dbtbpre}enewsgbook where bid='$bid' and checked=0"; //查询字段中添加like
第四步:修改e/class/t_functions.php
第2106行左右:
$listtemp=str_replace("[!--lyid--]",$r['lyid'],$listtemp);//id $listtemp=str_replace("[!--lytext--]",nl2br($r['lytext']),$listtemp);//留言内容 $listtemp=str_replace("[!--retext--]",nl2br($r['retext']),$listtemp);//回复 $listtemp=str_replace("[!--lytime--]",format_datetime($r['lytime'],$formatdate),$listtemp); $listtemp=str_replace("[!--name--]",$r['name'],$listtemp); $listtemp=str_replace("[!--like--]",$r['like'],$listtemp);
第五步:修改e/class/functions.php
第2934行左右添加:
$listtemp_center=str_replace("[!--lyid--]","<?=$r[lyid]?>",$listtemp_center); $listtemp_center=str_replace("[!--name--]","<?=$r[name]?>",$listtemp_center); $listtemp_center=str_replace("[!--like--]","<?=$r[like]?>",$listtemp_center);第六步:然后修改留言模板
(1)加入必填项:
<input name="like" type="text" id="gtitle" />(2)加入验证码:
<input type=text name=key><img src="/e/ShowKey/?v=gbook" onClick="this.src= this.src +'&xx='+Math.random()" alt="看不清楚,点击刷新">(3)后台开启留言验证: 系统参数修改------信息设置 —留言验证码
留言字段添加成功。
本文来源:爱折腾的摄影大叔—帝国cms记录—帝国CMS实现留言板功能验证码增加字段的方法
本文地址:https://www.lovezheteng.com/problem/dgwt/199.html
加入我们:微信:搜索“lovephoto588” 学习群:QQ一群---***
版权声明:本文采用[BY-NC-SA]协议进行授权,如无特别说明,转载请注明本文地址!