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.
1. Set a session in the form page

$_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.
if($_SESSION[post_only_once] == 1) {
// here doing insert to mysql
unset($_SESSION[post_only_once]); // remove the session after insert

1 comment:

Anonymous said...

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!