function main() { // check if the form has been submitted (orderEntryForm is just a hidden field) if (!array_key_exists("orderEntryForm", $_GET)) { showOrderEntryForm($_GET); } else { $badCustomerFields = customerValidate($_GET); $badOrderFields = orderValidate($_GET); $badFields = array_merge($badCustomerFields, $badOrderFields); if (count($badFields) != 0) { showOrderEntryForm($_GET, $badFields); } else { $CID = addCustomerToDataBase($_GET); $OID = addOrderToDataBase($CID, $_GET); orderConfirmation($OID); } } }
function main($OID) { global $repeatTimes; if (!array_key_exists("orderForm", $_GET)) { $data = takeOrderFromDataBase($OID); showOrderForm($data, ""); } else { $badFields = orderValidate($_GET); if (count($badFields) != 0) { showOrderForm($_GET, "", $badFields); } else { dbUpdate("orders", formatNonItemFields($_GET), "OID", $OID); for ($i = 1; $i < $repeatTimes; $i++) { $item = selectItem($_GET, $i); if (!empty($item)) { // checks to be sure the item actually has info if ($item["Quantity"] != 0) { if ($_GET["iid{$i}"] != "") { dbUpdate("items", $item, "OID", $OID, "IID", $_GET["iid{$i}"]); } else { // if the item does not yet exist in the database dbInsertNewItem($OID, $item); } } else { // if the quantity of an item is set to zero dbDeleteItem($_GET["iid{$i}"]); } } } // go back to the order page $config = getConfigData(); $backToOrder = getSpecialVariable("backToOrder", $config); backToWPPage($backToOrder, "oid={$OID}"); } } }