if (count($personName) != 3) { $errorInfo = "无效的用户名"; throw new Exception($errorInfo); } $person = PersonManager::getPerson($personName[1]); if ($person === false) { $errorInfo = "无效的用户名"; throw new Exception($errorInfo); } //获取书籍对象 $bookName = split("_", $bookName); if (count($bookName) != 3) { $errorInfo = "无效的书名"; throw new Exception($errorInfo); } $book = BookManager::getBook($bookName[1]); if ($book === false) { $errorInfo = "无效的书名"; throw new Exception($errorInfo); } if ($book->status != 0) { $errorInfo = "该书不在库中"; throw new Exception($errorInfo); } $ok = BookManager::borrowBookWithDate($book->bookId, $person->personId, $date); if ($ok === false) { $errorInfo = "操作失败"; throw new Exception($errorInfo); } else { $js = "<script>alert('借书成功');</script>"; echo "{$js}";
<?php require_once '../adminHeader.html'; ?> <?php require_once '../../models/book.php'; require_once '../../models/record.php'; if ($_SERVER['REQUEST_METHOD'] == 'GET') { $bookId = $_GET['bookId']; $book = BookManager::getBook($bookId); if ($books === false) { echo "<script>history.back();alert('没有数据');</script>"; return; } $records = RecordManager::searchRecordsWithPersonName($bookId); } ?> <!DOCTYPE html> <html lang="en"> <head> <?php require_once "../adminHead.php"; ?> </head> <body> <?php require_once "../adminNav.html";