ra****@satyam.net.in (Raju V.K) writes:
I am developing a PHP-mysql database. It is noted that when the
browser window is refreshed the data is inserted again in the
database. unfortunately there is no unique keys that I can use to
verify the existance of the data, so as to prevent the multiple
insertion. Is there any other way to prevent it otherthan introducing
another field for this purpose and verifying its existance?
You can use session variables to flag that the insert operation has
occurred once. i.e.
if (!isset($_SESSION["PAGE_NAME_INSERT"]))
{
/* Do the insertion operation */
$_SESSION["PAGE_NAME_INSERT"]=true;
}
else
{
/* The value have already been inserted. */
}
Note that at the page which sends the data to the page which actually
does the insertion, you might want to unset the
$_SESSION["PAGE_NAME_INSERT"] variable. This is needed if the user
presses "Back" and then changes some values in the form and resubmits.
--
Raj Shekhar
System Administrator, programmer and slacker
home :
http://rajshekhar.net
blog :
http://rajshekhar.net/blog/