Example #1
0
<?php

require "app/app.php";
session_start();
if (isset($_GET['logout'])) {
    session_start();
    session_destroy();
    header("Location: http://" . $_SERVER['HTTP_HOST'] . "/");
    exit;
}
if (isset($_GET['change_rec'])) {
    switch ($_POST['action']) {
        case 'Update':
            if ($_SESSION['table'] == 'book') {
                updateBook();
            }
            if ($_SESSION['table'] == 'category') {
                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':
Example #2
0
    }
    // Check file size
    if ($_FILES["fileToUpload"]["size"] > 500000) {
        echo "Sorry, your file is too large.";
        $uploadOk = 0;
    }
    // Check if $uploadOk is set to 0 by an error
    if ($uploadOk == 0) {
        updateBook($id, $shelf_id, "", $category_id, $title, $author, $type, $publish_year, $isbn_number, $pdf_link);
        // if everything is ok, try to upload file
    } else {
        if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
            echo "The file " . basename($_FILES["fileToUpload"]["name"]) . " has been uploaded.";
            $cover_picture = "uploads/" . $_FILES["fileToUpload"]["name"];
            // do crud
            updateBook($id, $shelf_id, $cover_picture, $category_id, $title, $author, $type, $publish_year, $isbn_number, $pdf_link);
        } else {
            echo "Sorry, there was an error uploading your file.";
        }
    }
}
if ($_GET) {
    $id = get("id");
    $book = getBook($id);
}
?>

<div class="row">
	<div class="col-lg-12">
		<h3 class="">Books</h3>
		<hr/>