forked from panakuma/book-lib-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_data.php
26 lines (25 loc) · 1.05 KB
/
update_data.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
require_once '../conf/DbManager.php';
require_once 'IsbnConsistencyCheck.php';
try {
if (empty($_POST['ISBN'])) throw new Exception('ISBNが指定されていません。');
if (IsbnConsistencyCheck($_POST['ISBN'])) throw new Exception('ISBNが間違っている可能性があります。');
$db = getDb();
$sql = "UPDATE books SET title = ?, author = ?, publisher = ?, genre = ? WHERE ISBN = ?";
$stmt = $db->prepare($sql);
$stmt->bindValue(1, $_POST['title'], PDO::PARAM_STR);
$stmt->bindValue(2, $_POST['author'], PDO::PARAM_STR);
$stmt->bindValue(3, $_POST['publisher'], PDO::PARAM_STR);
$stmt->bindValue(4, $_POST['genre'], PDO::PARAM_STR);
$stmt->bindValue(5, $_POST['ISBN'], PDO::PARAM_STR);
$stmt->execute();
$db = null;
echo "蔵書情報の更新が完了しました。<br>";
echo "<a href=\"./\">リストに戻る</a>";
}
catch (Exception $e) {
echo "エラーが発生しました: " . h($e->getMessage()) . "";
echo "<br><a href=\"./\">リストに戻る</a>";
die();
}
?>