Beispiel #1
0
<?php

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    require_once '../../models/book.php';
    require_once '../../models/person.php';
    $bookName = $_POST['bookName'];
    $personName = $_POST['personName'];
    $date = $_POST['date'];
    try {
        //获取用户对象
        $personName = split("_", $personName);
        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);
        }