通過本教程可以實現帝國CMS留言板增加字段以及增加驗證碼的教程:
第一步:
在數據庫的前綴名_enewsgbook表中添加您要顯示的字段,比如我要加標題"gtitle"字段,可以用工具添加,也可以執行sql添加:ALTER TABLE 前綴名_enewsgbook ADD gtitle VARCHAR(100);
第二步:
修改e/enews/gbookfun.php
第11行左右:
1 2 3 4 5 6 7 | $name =RepPostStr(trim( $add [name])); $email =RepPostStr( $add [email]); $call =RepPostStr( $add [call]); $lytext =RepPostStr( $add [lytext]); $gtitle =RepPostStr(trim( $add [gtitle])); //增加的gtitle if ( empty ( $bid )|| empty ( $gtitle )|| empty ( $name )|| empty ( $email )||!trim ( $lytext )) //gtitle字段檢測不允許為空 |
第56行左右:
1 | $sql = $empire ->query( "insert into {$dbtbpre}enewsgbook(name,gtitle,email,`call`,lytime,lytext,retext,bid,ip,checked,userid,username) values('$name','$gtitle','$email','$call','$lytime','$lytext','','$bid','$ip','$br[checked]','$userid','$username');" ); //插入字段記錄 |
注意此處,有兩處都要加入字段,而且位置要一樣,比如此處,gtitle 是在name后面,那兩個位置都要在 name后面
3、修改e/data/template/gbooktemp.txt
第50行左右
1 | $query = "select lyid,name,gtitle,email,`call`,lytime,lytext,retext from {$dbtbpre}enewsgbook where bid='$bid' and checked=0" ; //查詢字段中添加gtitle |
4、修改e/class/t_functions.php
第2106行左右
1 2 3 4 5 6 | $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 ( "[!--gtitle--]" , $r [ 'gtitle' ], $listtemp ); |
5、修改e/class/functions.php
第2934行左右添加
1 2 3 | $listtemp_center = str_replace ( "[!--lyid--]" , "" , $listtemp_center ); $listtemp_center = str_replace ( "[!--name--]" , "" , $listtemp_center ); $listtemp_center = str_replace ( "[!--gtitle--]" , "" , $listtemp_center ); |
6、然后修改留言模板
(1)加入必填項:
(2)加入驗證碼:
(3)后臺開啟留言驗證: 系統參數修改------信息設置 ---留言驗證碼
至此,留言字段添加成功。
后臺顯示:
在e/admin/tool/gbook.php找到$query="select的查詢語句,在末尾加入lytitle(記住加到末尾)
然后在頁面使用<?=$r[lytitle]?>調用就行了;(這里也應該在模板中改才行)
后臺回復留言頁:直接在頁面(e/admin/tool/regbook.php)加入<?=$r[lytitle]?>就行了
新聞熱點
疑難解答