Home > Backend Development > PHP Tutorial > How to prevent repeated data insertion when refreshing the web page_PHP tutorial

How to prevent repeated data insertion when refreshing the web page_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:51:45
Original
970 people have browsed it

There are many and very simple methods on how to prevent repeated data insertion when refreshing the web page. Below we will provide several reference processing methods.

There are many and very simple methods on how to prevent repeated data insertion when refreshing the web page. Below we will provide several reference processing methods.

How to prevent refreshing the web page from inserting data
I made a message board, but information will be inserted every time I refresh it. How can I prevent data from being inserted after refreshing?

JS returns after each operation
$regs=mysql_query($shouruinsert,$conn);
if($regs) echo "<script>window.alert("Operation successful");</script>Your income has been stored, please Return. Do not refresh this page to avoid repeated submission<script>window.location.href='inout.htm';</script>";
}
else{
echo "<script>window.alert("Operation failed");</script> Please check whether the data you submitted is standardized or contact the administrator! !";}

You can generate a cookie on the publishing page. On the submission page, if the submission is successful, the cookie will be cleared. When refreshing, just determine whether the cookie exists

Another method is to directly determine after querying the database,

if($regs){

die('is exisit');

}else{

mysql_.....

}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632538.htmlTechArticleThere are many and very simple methods on how to prevent repeated data insertion when refreshing the web page. Below we will provide several references. How to deal with it. Regarding how to prevent repeated data insertion when refreshing the web page...
source:php.cn
Statement of this Website
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
Latest Issues
Framework error
From 1970-01-01 08:00:00
0
0
0
Can anyone help me take a look?
From 1970-01-01 08:00:00
0
0
0
Composer cannot install laravel
From 1970-01-01 08:00:00
0
0
0
homestead - laravel new app reports error
From 1970-01-01 08:00:00
0
0
0
composer installation failed
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template