Home  >  Article  >  Backend Development  >  PHP提交表单为啥一次提交两条记录

PHP提交表单为啥一次提交两条记录

WBOY
WBOYOriginal
2016-06-13 12:15:441143browse

PHP提交表单为何一次提交两条记录
前端是一个form中有两个submit,通过js来实现点击两个button,一个提交到另一个页面,一个提交到自身。提交到另外一个页面实现插入数据库操作后再返回本页面显示。但是一次插入就会有两条记录。这怎么解决呢?
------解决思路----------------------
这个应该是你的JS提交了一次,然后submit这个又触发了一次,导致触发了2次

所以如果你要用JS来触发,那么你要先限制submit本身的触发
------解决思路----------------------
估计楼主的意思是这样的。

提交到后台,同时在本显进行展示


其实有两种方法

1,提交到后台,然后再跳转到当前页面(等于重新查询获取一次)

2,无刷新提交并展示,可以用Ajax

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn