-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex_admin.php
124 lines (102 loc) · 2.79 KB
/
index_admin.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
session_start();
// $username = $_SESSION['name'];
if (isset($_SESSION['user_id'])) { //ログインしているとき
$msg = 'こんにちは' . htmlspecialchars($_SESSION['name'], \ENT_QUOTES, 'UTF-8') . 'さん';
$msg2 = 'id:' . htmlspecialchars($_SESSION['user_id']);
$link = '<a href="logout.php">ログアウト</a>';
} else { //ログインしていない時
$msg = 'ログインしていません';
$link = '<a href="login_form.php">ログイン</a>';
}
//データベースに接続
$dsn = 'mysql:dbname=*******;host=localhost';
$user = '*******';
$password = '********';
try{
$dbh = new PDO($dsn, $user, $password);
}catch (PDOException $e){
print('Error:'.$e->getMessage());
die();
}
$id = $_SESSION['user_id'];
//ユーザー情報の取得
$sql ="
SELECT *
FROM login
WHERE id = :id
";
$stmt = $dbh->prepare($sql);
$stmt->bindValue("id", $id);
$stmt->execute();
$user = $stmt->fetch();
//リダイレクト処理
if (isset($_SESSION['user_id'])) {//ログインしているとき
if($user['status'] != 1){
//管理者か確認
printf("あなたは管理者ではありません。");
exit();
}
} else {//ログインしていない時
header('Location: ./login_form.php');
exit();
}
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>シュシュ勤怠管理システム</title>
<link rel="stylesheet" href="index.css">
</head>
<body>
<a href="index_admin.php" style="text-decoration:none;">
<header>
<div class="container">
<h1>シュシュ勤怠管理システム</h1>
</div>
</header>
</a>
<div class="user">
<div class="container">
<h1><?php echo $msg; ?></h1>
<h2><?php echo $msg2; ?></h2>
</div>
</div>
<div class="container">
<section>
<article>
<a href="shift_list.php" style="text-decoration:none;">
<div clas="container2">
<p>申請シフト</p>
</div>
</a>
</article>
<article>
<a href="request_close.php" style="text-decoration:none;">
<div clas="container2">
<p>申請締切</p>
</div>
</a>
</article>
<article>
<a href="confirmed_shift_list.php" style="text-decoration:none;">
<div clas="container2">
<p>確定シフト</p>
</div>
</a>
</article>
<article>
<a href="setting.php" style="text-decoration:none;">
<div clas="container2">
<p>設定</p>
</div>
</a>
</article>
</section>
</div>
<div class="container">
<?php echo $link; ?>
</div>
</body>
</html>