Design
Resources
Page 1, 2, 3, 4.
Notice that the redirect is the very last portion. This script submits to its self and redirects to the same page "#", a dummy url.
Script Clean-up
The code generated by DW is bloated and full of redundant calls to functions. For one, the mysql_select_db() is required only once for all actions on the page. The insertGoTo variables for the redirect are unnecessary because we know the app isn't going to pass any URL name/value pairs, so that can go.
The function GetSQLValueString(), performs 2 actions, if php's magic quotes isn't on, addSlashes() to the form value; then format the value according to the case passed with the call to the function e.g.,
GetSQLValueString($_POST['r3v2'], "text"
However the function includes a lot of cases that do not apply. After checking all the values we will throw at this function, the only formats required are "text", "int", and "date". The other cases can be deleted from the switch.
We're perfectly capable of entering a value into the form attribute for the file to submit the form to, so this renders the following code snippet as bloat;
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
Since no URL name/value pairs are required in this example, it can go. DW also has a penchant for very, very long variable names. This makes the code descriptive, but very long. So in most cases, it's easy to shorten those names using Edit > Find/Replace > Source and ignoring white space& case.
DW will also insert a hidden form field as a controller to stop server-side code from executing until the form is submitted. It's not required. Delete that MM_insert form field then just use the value of the Submit button i.e.
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "mInsert")){
to;
if ((isset($_POST["Submit"])) && ($_POST["Submit"] == "Submit")){
... NEXT :: Page 1, 2, 3, 4.