您当前未登录    免费注册    会员登录   
查看:631   回复:543

留言的表单放在网站的所有页面,这个提交数据库函数应该怎么写呢?

网络民工
网络民工

我把留言表单 放在网站底部的模板 做成弹出层的留言形式,可是点提交就到了留言的原地址  这个怎么改下呢

<form action="{xiaocms:function.url('index/form', array('modelid'=>3, 'cid'=>$id))}" method="post" name="guestbook" >

1楼2014-06-26 17:45:37 回复
26
kfnpzn

提交地址直接用后台表单模型那里给的提交地址就可以了。

还有个地方要改下,就是提交完成之后会自动跳转到提交地址的页面,这个要改一下core/controller/index.php的public function formAction()这个方法,把提交表单之后自动跳转那些代码去掉。反正我是这样改的,没出什么问题。

就是从$this->view->assign(array(到$this->view->display($form_model['showtpl']);这一行的都注释掉

2楼2014-06-27 09:08:48 回复
1
admin
提交表单 有个gobackurl 值 表单里面如果有这个参数 那么 就会提交后返回到这个gobackurl地址
3楼2014-06-27 10:35:00 回复
47
网络民工

感谢老大,和楼上的朋友,

不过我这个,不是返回,是点提交 无法提交到数据库 只是跳到在线留言那个地址,下面这样的方式不能用么?

还有我下载了最新的程序,怎么添加的留言自定义字段,还是不显示呢?

<form action="/index.php?c=index&a=form&modelid=3" method="post" name="guestbook" >
  <div class="input-area">

   <table>
    <colgroup>
     <col width="14%" />
     <col width="35%" />
     <col width="12%" />
     <col width="39%" />
    </colgroup>
    <tr>
     <th>您的姓名</th>
     <td><input type="text" class="required" name="data[nindexingming]" id="nindexingming" /><span class="required">*</span></td>
     <th>您的公司</th>
     <td>
     <input type="text" class="required" name="data[nindegongsi]" id="nindegongsi" /></td>
    </tr>
    <tr>
     <th>您的电话</th>
     <td><input type="text" class="required" name="data[nindedianhua]" id="nindedianhua" /><span class="required">*</span></td>
     <th>您的QQ</th>
     <td><input type="text" name="data[lianxiQQ]" id="lianxiQQ" /></td>
    </tr>
    <tr>
     <th>Email</th>
     <td><input type="text" name="data[nindeyouxiang]" id="nindeyouxiang" /></td>
     <th>公司网址</th>
     <td><input type="text" name="data[gongsiwangzhi]" id="gongsiwangzhi" /></td>
    </tr>
    <tr>
     <th>留言内容</th>
     <td colspan="3"><textarea name="data[liuyanneirong]" id="content" cols="20" rows="4" ></textarea><span class="required">*为必填项</span></td>
    </tr>
   </table>
  </div>
  <div class="btn-area">
   <input type="submit" value="提 交" />
  </div>
 </form>

4楼2014-06-27 12:51:53 回复
26
kfnpzn

POST提交的话,action改成/index.php,然后再加三这三个

<input type="hidden" name="c" value="index" />

<input type="hidden" name="a" value="form" />

<input type="hidden" name="modelid" value="3" />

试一下这样行不行,刚开始我也遇到跟你这样的问题,后面我也忘记怎么弄好了。好像就是这样弄的。

5楼2014-06-28 10:57:43 回复
47
网络民工

非常感谢。但是也不行,数据提交不到数据库。。

6楼2014-06-28 14:35:50 回复
24
kehebiao

<input type="submit" class="button" value="提 交" name="submit">

写完整吧,提交代码里 需要 submit 名称段做提交判断

7楼2014-06-28 22:27:57 回复
快速回复