关于怎么防止刷新网页重复插入数据方法很多也很简单的,下面我们就来提供几种参考的处理方法吧。
如何防止刷新网页插入数据:
我做了一个留言板,但是每次刷新就会插入信息,请问怎么做才能防止刷新插入数据呢
JS每次操作后返回
<?php $regs=mysql_query($shouruinsert,$conn); if($regs) echo "<script>window.alert(\"操作成功\");</script><font size=3><a href=inout.htm>你的收入已经入库,请返回.不要刷新本页以免重复提交</a></font><script>window.location.href='inout.htm';</script>"; } else{ echo "<script>window.alert(\"操作失败\");</script><font size=3><a href=inout.htm>请检查你提交的数据是否规范或者联系管理员!!</a></font>"; } ?>
可以在发表页生成个cookie,在提交页,如果提交成功了就把这个cookie清了,这个刷新的时候判断cookie是否存在就可以了
还有和种方法就是查询数据库之后直接判断,
if($regs){ die('is exisit'); }else{ mysql_..... }
本文地址:
转载随意,但请附上文章地址:-)

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version
Recommended: Win version, supports code prompts!

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
