$field) { if (!isset($field["privileges"][$update ? "update" : "insert"]) || !strlen($adminer->fieldName($field))) { unset($fields[$name]); } } if ($_POST && !$error && !isset($_GET["select"])) { $location = $_SERVER["REQUEST_URI"]; // continue edit or insert if (!$_POST["insert"]) { $location = ME . "select=" . urlencode($TABLE); $i = 0; // append &set converted to &where foreach ((array) $_GET["set"] as $key => $val) { if ($val == $_POST["fields"][$key]) { $location .= where_link($i++, bracket_escape($key, "back"), $val); } } } $set = array(); foreach ($fields as $name => $field) { $val = process_input($field); if ($val !== false || !$update) { $set[] = "\n" . idf_escape($name) . " = " . ($val !== false ? $val : "''"); } } if (!$set) { redirect($location); } if ($update) { query_redirect("UPDATE " . idf_escape($TABLE) . " SET" . implode(",", $set) . "\nWHERE $where\nLIMIT 1", $location, lang('Item has been updated.')); } else { query_redirect("INSERT INTO " . idf_escape($TABLE) . " SET" . implode(",", $set), $location, lang('Item has been inserted.')); } } $table_name = $adminer->tableName(table_status($TABLE)); page_header( ($update ? lang('Edit') : lang('Insert')), $error, array("select" => array($TABLE, $table_name)), $table_name ); unset($row); if ($_POST["save"]) { $row = (array) $_POST["fields"]; } elseif ($where) { $select = array(); foreach ($fields as $name => $field) { if (isset($field["privileges"]["select"])) { $select[] = ($_POST["clone"] && $field["auto_increment"] ? "'' AS " : (ereg("enum|set", $field["type"]) ? "1*" . idf_escape($name) . " AS " : "")) . idf_escape($name); } } $row = array(); if ($select) { $result = $connection->query("SELECT " . implode(", ", $select) . " FROM " . idf_escape($TABLE) . " WHERE $where " . (isset($_GET["select"]) ? "HAVING COUNT(*) = 1" : "LIMIT 1")); $row = $result->fetch_assoc(); } } ?>