织梦dede自定义表单自动获取IP地址和提交时间

2025-11-21 18:15:54

1、第一步:在根目录中找到plus/diy.php文件,然后查找下面的代码

  if($fieldinfo[1] == 'textdata')

  {

  ${$fieldinfo[0]} = FilterSearch(stripslashes(${$fieldinfo[0]}));

  ${$fieldinfo[0]} = addslashes(${$fieldinfo[0]});

  }

后面添加

  if($fieldinfo[0] == 'ip')

  {

  ${$fieldinfo[0]}=GetIP();

  }

  if($fieldinfo[0] == 'time')

  {

  ${$fieldinfo[0]}=date("Y-m-d H:i:s");

  }

添加完后代码如下图:

织梦dede自定义表单自动获取IP地址和提交时间

2、第二步:后台添加对应字段(也就是要抓取的IP和time字段)

网站后台找到自定义表单---->编辑---->添加字段

织梦dede自定义表单自动获取IP地址和提交时间

织梦dede自定义表单自动获取IP地址和提交时间

织梦dede自定义表单自动获取IP地址和提交时间

3、第三步:修改前端html页面

找到你网站提交信息页面的模板文件,然后查找下面的代码:

<input type="hidden" name="dede_fields"

如图:

织梦dede自定义表单自动获取IP地址和提交时间

4、第四步:在第三步找到的代码前面添加下面的信息:

(重要提示:第二步添加的字段要跟下面中的name相互对应)

<input type="hidden" name="ip" id="ip" value="">

<input type="hidden" name="time" id="time" value="">

织梦dede自定义表单自动获取IP地址和提交时间

5、第五步:给第三步中找到的代码添加信息:ip,text;time,text

例如:

<input type="hidden" name="dede_fields" value="city,select;area,text;shi,select;ting,select;chu,select;wei,select;yangtai,select;xm,text;tel,text;dizhi,text;fengge,text" />

添加后(加粗的代码就是需要添加的代码):

<input type="hidden" name="dede_fields" value="city,select;area,text;shi,select;ting,select;chu,select;wei,select;yangtai,select;xm,text;tel,text;dizhi,text;fengge,text;ip,text;time,text" />

织梦dede自定义表单自动获取IP地址和提交时间

6、最后提醒大家,如果您在修改以后发现提示:“数据校验不对,程序返回”,请点击下面链接

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢