hasErrors()) { $_SESSION['errors']['form-edit-'] = $validator->getAllErrors(); } else { require_once CLASS_DIR . 'phpformbuilder/database/db-connect.php'; require_once CLASS_DIR . 'phpformbuilder/database/Mysql.php'; $db = new Mysql(); $filter[""] = Mysql::SQLValue($_SESSION['_editable_primary_key'], Mysql::SQLVALUE_NUMBER); $db->throwExceptions = true; try { // begin transaction $db->transactionBegin(); // update if (DEMO !== true && !$db->updateRows('', $update, $filter)) { $error = $db->error(); $db->transactionRollback(); throw new \Exception($error); } else { if (!isset($error)) { // ALL OK $db->transactionEnd(); $_SESSION['msg'] = Utils::alert(UPDATE_SUCCESS_MESSAGE, 'alert-success has-icon'); // reset form values Form::clear('form-edit-'); // redirect to list page if (isset($_SESSION['active_list_url'])) { header('Location:' . $_SESSION['active_list_url']); } else { header('Location:' . ADMIN_URL . ''); } // if we don't exit here, $_SESSION['msg'] will be unset exit(); } } } catch (\Exception $e) { $msg_content = DB_ERROR; if (ENVIRONMENT == 'development') { $msg_content .= '
' . $e->getMessage() . '
' . $db->getLastSql(); } $_SESSION['msg'] = Utils::alert($msg_content, 'alert-danger has-icon'); } } // END else } // END if POST $ = $pk; // register editable primary key, which is NOT posted and will be the query update filter $_SESSION['_editable_primary_key'] = $; if (!isset($_SESSION['errors']['form-edit-']) || empty($_SESSION['errors']['form-edit-'])) { // If no error registered $qry = "SELECT * FROM ``"; $transition = 'WHERE'; // if restricted rights if (ADMIN_LOCKED === true && Secure::canUpdateRestricted('')) { $qry .= Secure::getRestrictionQuery(''); $transition = 'AND'; } $qry .= ' ' . $transition . " . = '$'"; $db = new Mysql(); // echo $qry . '
'; $db->query($qry); if ($db->rowCount() < 1) { if (DEBUG === true) { exit($db->getLastSql() . ' : No Record Found'); } else { Secure::logout(); } } $row = $db->row(); } $form = new Form('form-edit-', 'horizontal', 'novalidate', 'bs4'); $form->setAction(ROOT_RELATIVE_URL . 'admin//edit/' . $); $form->startFieldset(); $form->setCols(2, ); $form->addBtn('button', 'cancel', 0, '' . CANCEL, 'class=btn btn-warning ladda-button legitRipple, onclick=history.go(-1)', 'btn-group'); $form->addBtn('submit', 'submit-btn', 1, SUBMIT . '', 'class=btn btn-success ladda-button legitRipple', 'btn-group'); $form->setCols(0, 12); $form->centerButtons(true); $form->printBtnGroup('btn-group'); $form->endFieldset(); $form->addPlugin('nice-check', 'form', 'default', array('%skin%' => 'green'));