Fixed Bug #972744: "insert row" is may insert item multiple times
authormr-russ <mr-russ>
Sun, 13 Mar 2005 23:15:14 +0000 (23:15 +0000)
committermr-russ <mr-russ>
Sun, 13 Mar 2005 23:15:14 +0000 (23:15 +0000)
HISTORY
lang/english.php
tables.php

diff --git a/HISTORY b/HISTORY
index ed52d7e150a41d5f21dbf03256bbb192aa85c703..7d72a3e423808dd9658ae4ec1ae98e6316d1b353 100644 (file)
--- a/HISTORY
+++ b/HISTORY
@@ -25,6 +25,7 @@ Bugs
 * Fix using schema enabled dump on non-schema enabled backend
 * Reload browser after executing arbitrary SQL
 * Fix inability to drop database using the drop link
+* Stop duplicate insert on re-POST of data
 
 Translations
 * Japanese from Tadashi Jokagi
index 24893475ac0aa03214275c1c95cdc91c3f108ab5..0437bb2127ae8ccebda27d27dcb465524e94419a 100755 (executable)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.169 2005/01/04 23:49:17 soranzo Exp $
+        * $Id: english.php,v 1.170 2005/03/13 23:15:17 mr-russ Exp $
         */
 
        // Language and character set
        $lang['strinsertrow'] = 'Insert row';
        $lang['strrowinserted'] = 'Row inserted.';
        $lang['strrowinsertedbad'] = 'Row insert failed.';
+       $lang['strrowduplicate'] = 'Row insert failed, attempted to do duplicate insert.';
        $lang['streditrow'] = 'Edit row';
        $lang['strrowupdated'] = 'Row updated.';
        $lang['strrowupdatedbad'] = 'Row update failed.';
index 2450f5c9d3d14a8cfa190165292d4bdb6f3938f1..a2d07df75d3608f51c6d368554d1f66cfca87b1c 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List tables in a database
         *
-        * $Id: tables.php,v 1.69 2005/01/23 12:42:35 soranzo Exp $
+        * $Id: tables.php,v 1.70 2005/03/13 23:15:15 mr-russ Exp $
         */
 
        // Include application functions
                                echo "</table></p>\n";
                        }
                        else echo "<p>{$lang['strnodata']}</p>\n";
+                       
+                       if (!isset($_SESSION['counter'])) { $_SESSION['counter'] = 0; }
 
                        echo "<input type=\"hidden\" name=\"action\" value=\"insertrow\" />\n";
+                       echo "<input type=\"hidden\" name=\"protection_counter\" value=\"".$_SESSION['counter']."\" />\n";
                        echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\" />\n";
                        echo $misc->form;
                        echo "<p><input type=\"submit\" name=\"insert\" value=\"{$lang['strinsert']}\" />\n";
                        if (!isset($_POST['values'])) $_POST['values'] = array();
                        if (!isset($_POST['nulls'])) $_POST['nulls'] = array();
 
-                       $status = $data->insertRow($_POST['table'], $_POST['values'], 
-                                                                                               $_POST['nulls'], $_POST['format'], $_POST['types']);
-                       if ($status == 0) {
-                               if (isset($_POST['insert']))
-                                       doDefault($lang['strrowinserted']);
-                               else {
-                                       $_REQUEST['values'] = array();
-                                       $_REQUEST['nulls'] = array();
-                                       doInsertRow(true, $lang['strrowinserted']);
+                       if ($_SESSION['counter']++ == $_POST['protection_counter']) {
+                               $status = $data->insertRow($_POST['table'], $_POST['values'], 
+                                                                                                       $_POST['nulls'], $_POST['format'], $_POST['types']);
+                               if ($status == 0) {
+                                       if (isset($_POST['insert']))
+                                               doDefault($lang['strrowinserted']);
+                                       else {
+                                               $_REQUEST['values'] = array();
+                                               $_REQUEST['nulls'] = array();
+                                               doInsertRow(true, $lang['strrowinserted']);
+                                       }
                                }
-                       }
-                       else
-                               doInsertRow(true, $lang['strrowinsertedbad']);
+                               else
+                                       doInsertRow(true, $lang['strrowinsertedbad']);
+                       } else
+                               doInsertRow(true, $lang['strrowduplicate']);
                }
 
        }