Copy code The code is as follows:
/*
* How to prevent repeated submission of forms in php
*/
session_start();
if (empty($_SESSION['ip'])) {//The first write operation, determine whether the IP address is recorded, so as to know whether to Write to the database
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR']; //The first write will pave the way for subsequent refresh or retreat judgments
//..... ......//Write to database operation
} else {//There has been an operation after the first write, so it will no longer be written to the database
echo 'Please do not refresh and back off again' ; //Write some already written tips or other things
}
?>
Another way is:
1. Generate a random code on the page, that is, the random code is different every time you submit it. Verify the random code when submitting!
2. When submitting, verify that if the data exists, it will not be submitted.
http://www.bkjia.com/PHPjc/328093.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/328093.htmlTechArticleCopy the code code as follows: ?php /* * How to prevent repeated submission of forms in php*/ session_start(); if (empty($_SESSION['ip'])) {//The first write operation, determine whether the IP address is recorded,...
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