-
Notifications
You must be signed in to change notification settings - Fork 0
/
delschedule.php
executable file
·72 lines (64 loc) · 1.89 KB
/
delschedule.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale1">
<title>スケジュール削除 - カレンダー</title>
</head>
<body>
<?php
session_start();
require('dbconnect.php');
//削除用関数
function del($db,$No){
$sql2 = sprintf('DELETE FROM schedule WHERE No = "%d"',$No);
$record2 = mysqli_query($db, $sql2) or die(mysqli_error($db));
if($record2 = true){
print("削除が完了しました");
}else{
print("削除に失敗しました");
}
}
// ログイン状態のチェック
if (!isset($_SESSION["user"])) {
header("Location: login.php");
exit;
}
//アドレスから変数取得
if(isset($_GET['No'])) {
$No = $_GET['No'];
}
//NOが存在しない場合
if(!isset($No)){
print("Error!!!");
exit();
}
//削除できるかの確認。権限があれば削除関数を呼び出す
$sql = sprintf('SELECT Y.Edit, Y.Author_ID
FROM schedule X, cal_list Y, reg_list Z
WHERE X.No = "%d"
AND X.Cal_No = Y.Cal_No
AND X.Cal_No = Z.Cal_No
AND Z.ID = "%d"',
(int)$No,
(int)$_SESSION['user']);
$record = mysqli_query($db, $sql) or die(mysqli_error($db));
if($row = mysqli_fetch_assoc($record)){
if($row['Edit'] == 1){
if($row['Author_ID'] == $_SESSION['user']){
del($db,$No);
}else{
print("Error!!!");
}
}else{
del($db,$No);
}
}else{
print("Error!!!");
}
?>
<br />
<a href="#" onclick="javascript:window.history.back(-1);return false;"><=戻る</a>
</body>
</HTML>