'', 'code' => '', 'amount' => 0, 'start' => 0 ]; $editing = false; if (!empty($VARS['id'])) { if ($database->has('certificates', ['certid' => $VARS['id']])) { $editing = true; $carddata = $database->get( 'certificates', [ 'certid (id)', 'certcode (code)', 'amount', 'start_amount (start)' ], [ 'certid' => $VARS['id'] ]); } else { // customer id is invalid, redirect to a version of the page that won't // cause an error when pressing Save header('Location: app.php?page=editcertificate'); die(); } } if (!$editing) { // Generate gift certificate number do { $carddata['code'] = random_int(100000000000, 999999999999); } while ($database->has('certificates', ['certcode' => $carddata['code']])); } ?>

build("editing card x", ['code' => htmlspecialchars($carddata['code'])]); ?> get("adding card"); ?>