How to Protect from double posting insert MySQL
Posted by Jawaad on 5 November, 2008
No comments yet
Cara untuk supaya proteksi dari double posting suatu form ke dalam database menggunakan tehnik 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.
if($_SESSION[post_only_once] == 1) { // here doing insert to mysql } unset($_SESSION[post_only_once]); // remove the session after insert
Popularity: 9,527 views

(6 votes, average: 4.83 out of 5)