Ejemplo n.º 1
0
                updateCategory();
            }
            header("Location: http://" . $_SERVER['HTTP_HOST'] . "/");
            exit;
        case 'Delete':
            if ($_SESSION['table'] == 'book') {
                deleteBook();
            }
            if ($_SESSION['table'] == 'category') {
                deleteCategory();
            }
            header("Location: http://" . $_SERVER['HTTP_HOST'] . "/");
            exit;
        case 'Save':
            if ($_SESSION['table'] == 'book') {
                newBook();
            }
            if ($_SESSION['table'] == 'category') {
                newCategory();
            }
            header("Location: http://" . $_SERVER['HTTP_HOST'] . "/");
            exit;
    }
}
if (!$_SESSION['user_id']) {
    $error['{ERROR}'] = isset($_SESSION['error_login']) ? "<font color='#a52a2a'>" . $_SESSION['error_login'] . "</font>" : "";
    $params['{LOGIN}'] = getTpl("login", $error);
    login();
} else {
    $userName = getUserName();
    $params['{LOGIN}'] = "<p id=\"logout\">You enter as: " . $userName . "<br><a href=\"?logout\"> logout</a></p>";
Ejemplo n.º 2
0
<?php

message("Create new book");
message("---------------");
# TODO validate the rest of the input
$name = readline('Book Name: ');
$author = readline('Author: ');
$genre = readline('Genre: ');
$price = readline('Price: ');
$inStock = null;
while (!in_array($inStock, array('y', 'n'))) {
    $inStock = readline('In stock (y/n): ');
}
$book = array('name' => $name, 'author' => $author, 'genre' => $genre, 'price' => $price, 'in_stock' => $inStock == 'y' ? true : false);
$check = newBook($book);
if (false === $check) {
    message('Error! Book not saved.');
} else {
    message('Book saved successfully.');
}