質問編集履歴
1
別ファイルのソースコード追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,6 +10,8 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
|
13
|
+
index.php(ログインの画面)
|
14
|
+
|
13
15
|
```PHP
|
14
16
|
|
15
17
|
<?php
|
@@ -124,6 +126,90 @@
|
|
124
126
|
|
125
127
|
|
126
128
|
|
129
|
+
TOPのPHPファイル(ログイン完了後の画面)
|
130
|
+
|
131
|
+
```PHP
|
132
|
+
|
133
|
+
<?php
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
session_start();
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
//ログイン済みかを確認
|
142
|
+
|
143
|
+
if (!isset($_SESSION['USER'])) {
|
144
|
+
|
145
|
+
header('Location: index.php');
|
146
|
+
|
147
|
+
exit;
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
//ログアウト機能
|
154
|
+
|
155
|
+
if(isset($_POST['logout'])){
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
$_SESSION = [];
|
160
|
+
|
161
|
+
session_destroy();
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
header('Location: index.php');
|
166
|
+
|
167
|
+
exit;
|
168
|
+
|
169
|
+
}
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
?>
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
<!DOCTYPE html>
|
178
|
+
|
179
|
+
<html>
|
180
|
+
|
181
|
+
<head>
|
182
|
+
|
183
|
+
<title>トップ画面</title>
|
184
|
+
|
185
|
+
</head>
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
<body>
|
190
|
+
|
191
|
+
<h1>トップ画面</h1>
|
192
|
+
|
193
|
+
<p><?php echo $_SESSION['USER'] ?>さんでログイン中</p>
|
194
|
+
|
195
|
+
<br>
|
196
|
+
|
197
|
+
<form method="post" action="top.php">
|
198
|
+
|
199
|
+
<input type="submit" name="logout" value="ログアウト">
|
200
|
+
|
201
|
+
</form>
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
</body>
|
206
|
+
|
207
|
+
</html>
|
208
|
+
|
209
|
+
```
|
210
|
+
|
211
|
+
|
212
|
+
|
127
213
|
### 試したこと
|
128
214
|
|
129
215
|
|