关于怎么防止刷新网页重复插入数据方法很多也很简单的,下面我们就来提供几种参考的处理方法吧。
如何防止刷新网页插入数据:
我做了一个留言板,但是每次刷新就会插入信息,请问怎么做才能防止刷新插入数据呢
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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Linux new version
SublimeText3 Linux latest version

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