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() { if (array_key_exists("CID", $_GET)) { $CID = $_GET["CID"]; } else { print_r("ERROR: CID NOT FOUND"); $CID = 1; } if (!array_key_exists("customerForm", $_GET)) { $data = takeCustomerFromDataBase($CID); showCustomerForm($data, "", array()); // sends an empty array as the badFields } else { $badFields = customerValidate($_GET); // checks to make sure the info given is complete if (count($badFields) != 0) { showCustomerForm($_GET, "", $badFields); } else { // at this point we have good data, and just need to get it into the // database. Before we do it, get the OID from the form data so we // know whether we need to go back to the orders page or customer page $OID = NULL; if (array_key_exists("OID", $_GET)) { $OID = $_GET["OID"]; } $customer = formatForDataBase($_GET); $CID = dbUpdate("customers", $customer, "CID", $CID); // get the configuration information from the Wordpress page so we know where // our target "return to" pages are $config = getConfigData(); $backToOrder = getSpecialVariable("backToOrder", $config); $backToCustomer = getSpecialVariable("backToCustomer", $config); if ($OID) { // came from order backToWPPage($backToOrder, "oid={$OID}"); } else { // otherwise from a customer edit backToWPPage($backToCustomer, "CID={$CID}"); } } } }