Esempio n. 1
0
     include "add.html";
 } elseif (isset($_POST["search"])) {
     // user wants to search the database: show search form
     include "search.html";
 } elseif (isset($_POST["addBook"])) {
     // add a book to the database
     if (empty($_POST["author"]) || empty($_POST["title"]) || empty($_POST["genre"])) {
         // check if all fields are used, if not, tell user
         echo "<br /><b>You need to fill in all the fields!</b>";
     } else {
         // set variables
         $author = $_POST["author"];
         $title = $_POST["title"];
         $genre = $_POST["genre"];
         // insert book into database
         $library->insertBook($author, $title, $genre);
     }
 } elseif (isset($_POST["startAuthorSearch"])) {
     // search on author
     $author = $_POST["authorSearch"];
     $library->searchAuthor($author);
 } elseif (isset($_POST["startTitleSearch"])) {
     // search on title
     $title = $_POST["titleSearch"];
     $library->searchTitle($title);
 } elseif (isset($_POST["startGenreSearch"])) {
     // search on genre
     $genre = $_POST["genreSearch"];
     $library->searchGenre($genre);
 } elseif (isset($_POST["updateBook"])) {
     // user wants to update a book: show update form