Пример #1
0
<?php

require __DIR__ . "/../bourbon/genre.php";
$status_message = '';
// Status messages, default to nothing
$g = new Genre();
$g->auth(null);
$g->init(WEB::_get('id'));
if (!$g->valid()) {
    $status_message = WEB::_error('Genre couldn\'t be viewed. Check ID #!', null);
}
// Handle Post Request
if (WEB::_req('POST')) {
    $genre_name = WEB::_post('genre_name');
    // array($genre_name)
    $form_error = $g->validateParams(array($genre_name));
    if (is_null($form_error)) {
        if (!is_null($genre_name)) {
            $updateStatus = $g->updateGenre($genre_name);
        }
        if ($updateStatus) {
            $g->refresh();
            $status_message = WEB::_success('Genre Successfully updated!');
        } else {
            $status_message = WEB::_error('There is an error when you were updating the Genre. Please make sure you\'re not adding duplicates!', $form_error);
        }
    } else {
        $status_message = WEB::_error('There is an error when you were updating the Genre. Please review the form below!', $form_error);
    }
}
?>