static function submit() { // store data posted by the form in the session so it // is still available in case of redirection to the same form $_SESSION['activation_editmap'] = $_POST; // retrieve model instance $model = ActivationModel::getInstance(); // save or create the record $result = $model->save($_POST); $code = substr($result, 0, 2); if ($code == "OK") { $newRecord = $_POST['id'] == 0; // if this was a new record, show only this record in the list // if this was an existing record, keep the previous filter if ($newRecord) { $newId = substr($result, 2, strlen($result) - 2); $filter = "id=" . $newId; } else { $filter = $_SESSION['last_activations_filter']; } // redirect to the list ActivationsController::listRows($filter); } else { // redirect to the edit page with error message $result = str_replace("\n", "<br>", $result); // no newlines in headers! header("Location: activation_edit.php?error=" . $result); } }
function counterString() { // rows to be listed $datamap = $_SESSION['activation_datamap']; $partial = count($datamap); // total rows include_once 'model.php'; $model = ActivationModel::getInstance(); $total = $model->countRows(); // display counter $string = $partial . " of " . $total . " records"; return $string; }