-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwritePost.php
executable file
·58 lines (45 loc) · 1.27 KB
/
writePost.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
include "./script/dbconnect.php";
session_start();
ini_set('display_errors', '1');
$id = $_SESSION['isLoginId'];
$idx = $_POST['Idx'];
$title = $_POST['Title'];
$memo = $_POST['Memo'];
if (isset($_POST['MemoPassword'])) {
$password = $_POST['MemoPassword'];
}
else {
$password = "";
}
if (isset($_POST['IsSecret'])) {
$isSecret = $_POST['IsSecret'];
}
else {
$isSecret = 0;
}
if ($idx) {
$query = "SELECT * FROM memo WHERE Idx='$idx' and MemoPassword=password('$password')";
$result = $db->query($query)->fetchArray();
if (!$result['Idx']) {
echo "<script>
alert('Wrong Password');
history.back();
</script>";
exit;
}
$query = "UPDATE memo set Id='$id', Title='$title', Memo='$memo' where Idx='$idx' ";
$db->query($query);
}
else {
$regdate = date("Y-m-d H:i:s");
$query = "INSERT INTO memo(Id, Title, Memo, Regdate, MemoPassword, IsSecret) VALUES('$id', '$title', '$memo', '$regdate', password('$password'), $isSecret) ";
$db->query($query);
}
?>
<script>
location.href="list.php";
</script>
<?php
$db->close();
?>