-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.php
36 lines (31 loc) · 923 Bytes
/
update.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
27
28
29
30
31
32
33
34
35
36
<?php
include('functions.php');
//入力チェック(受信確認処理追加)
if (
!isset($_POST['task']) || $_POST['task'] == '' ||
!isset($_POST['deadline']) || $_POST['deadline'] == ''
) {
exit('ParamError');
}
//POSTデータ取得
$id = $_POST['id'];
$task = $_POST['task'];
$deadline = $_POST['deadline'];
$comment = $_POST['comment'];
//DB接続します(エラー処理追加)
$pdo = connectToDb();
//データ登録SQL作成
$sql = 'UPDATE php02_table SET task=:a1, deadline=:a2, comment=:a3 WHERE id=:id';
$stmt = $pdo->prepare($sql);
$stmt->bindValue(':a1', $task, PDO::PARAM_STR);
$stmt->bindValue(':a2', $deadline, PDO::PARAM_STR);
$stmt->bindValue(':a3', $comment, PDO::PARAM_STR);
$stmt->bindValue(':id', $id, PDO::PARAM_INT);
$status = $stmt->execute();
//4.データ登録処理後
if ($status == false) {
showSqlErrorMsg($stmt);
} else {
header('Location: select.php');
exit;
}