-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave.php
More file actions
56 lines (50 loc) · 1.34 KB
/
save.php
File metadata and controls
56 lines (50 loc) · 1.34 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
$id=NULL;
if (! empty($_POST['id']) ) {
$id = intval($_POST['id']);
$task = "更新";
} else {
$task = "保存";
}
// 確認用表示
$DateTime = htmlspecialchars($_POST['DateTime']);
$Subject = htmlspecialchars($_POST['Subject']);
$Detail = htmlspecialchars($_POST['Detail']);
echo<<<EOT
<table borderwith='1'>
<tr><th align="left">DateTime</th><td>$DateTime</td></tr>
<tr><th align="left">Subject</th><td>$Subject</td>
<tr><th colspan="2" align="left">Detail</th></tr>
<tr><td></td><td>$Detail</td></tr>
</table>
EOT;
//var_dump($_POST);
$datetime = ($_POST['DateTime']);
$subject = ($_POST['Subject']);
$detail = ($_POST['Detail']);
if (isset($id)) {
try {
$num = updateTodo($pdo, $id, $datetime, $subject, $detail);
} catch (\PDOException $e) {
error_log( "\PDO::例外: " . $e->getMessage() );
return;
}
error_log("UPDATE: affected lins = $num");
} else {
try {
$id = insertTodo($pdo, $datetime, $subject, $detail);
} catch (\PDOException $e) {
error_log( "\PDO::例外: " . $e->getMessage() );
return;
}
error_log("INSERT: new id = $id");
}
?>
<center>
<table borderwith='1'>
<tr>
<td>[<a href="<?php {echo $_SERVER['SCRIPT_NAME'];}?>?mode=list">一覧</a>]</td>
<td>[<a href="<?php {echo $_SERVER['SCRIPT_NAME'];}?>?mode=edit&id=<?php {echo $id;}?>">再編集</a>]</td>
</tr>
</table>
</center>