How to Protect from double posting insert MySQL
Submit once even the visitor is refresh the page from browser.
Here is the way to protect.
Use a SESSION.
1. Set a session in the form page
session_start();
$_SESSION[post_only_once] = 1;
echo "
< form method=\"post\">
Name < input type=\"text\" name=\"name\">
< input type=\"submit\" value=\"submit\" name=\"submit\">
< /form>
";
2. Check the session before doing INSERT into MySQL.
session_start();
if($_SESSION[post_only_once] == 1) {
// here doing insert to mysql
}
unset($_SESSION[post_only_once]); // remove the session after insert
1 comment:
Who knows where to download XRumer 5.0 Palladium?
Help, please. All recommend this program to effectively advertise on the Internet, this is the best program!
Post a Comment