質問編集履歴

1

ソースコードを改めました

2018/07/07 10:36

投稿

laminne
laminne

スコア80

test CHANGED
File without changes
test CHANGED
@@ -44,23 +44,29 @@
44
44
 
45
45
  ```php
46
46
 
47
+ <?php
48
+
49
+ session_start();
50
+
51
+ ?>
52
+
47
53
  <!DOCTYPE html>
48
54
 
49
55
  <html lang="ja">
50
56
 
51
57
  <head>
52
58
 
53
- <meta charset="UTF-8">
59
+ <meta charset="UTF-8">
54
-
60
+
55
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
61
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
56
-
62
+
57
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
63
+ <meta http-equiv="X-UA-Compatible" content="ie=edge">
58
-
64
+
59
- <title>ひとこと掲示板</title>
65
+ <title>ひとこと掲示板</title>
60
-
61
-
62
-
66
+
67
+
68
+
63
- <link rel="stylesheet" href="../style.css" />
69
+ <link rel="stylesheet" href="../style.css" />
64
70
 
65
71
  </head>
66
72
 
@@ -78,193 +84,197 @@
78
84
 
79
85
  <div id="content">
80
86
 
81
- <?php
82
-
83
- require('dbconnect.php');
84
-
85
-
86
-
87
- session_start();
88
-
89
-
90
-
91
- if ($_COOKIE['email'] != '') {
92
-
93
- $_POST['email'] = $_COOKIE['email'];
94
-
95
- $_POST['password'] = $_COOKIE['password'];
96
-
97
- $_POST['save'] = 'on';
98
-
99
- }
100
-
101
-
102
-
103
- if (!empty($_POST)) {
104
-
105
- // ログインの処理
106
-
107
- if ($_POST['email'] != '' && $_POST['password'] != '') {
108
-
109
- $login = $db->prepare('SELECT * FROM members WHERE email=? AND password=?');
110
-
111
- $login->execute(array(
112
-
113
- $_POST['email'],
114
-
115
- sha1($_POST['password'])
116
-
117
- ));
118
-
119
- $member = $login->fetch();
120
-
121
-
122
-
123
- if ($member) {
124
-
125
- // ログイン成功
126
-
127
- $_SESSION['id'] = $member['id'];
128
-
129
- $_SESSION['time'] = time();
130
-
131
-
132
-
133
- // ログイン情報を記録する
134
-
135
- if ($_POST['save'] == 'on') {
136
-
137
- setcookie('email', $_POST['email'], time()+60*60*24*14);
138
-
139
- setcookie('password', $_POST['password'], time()+60*60*24*14);
140
-
141
- }
142
-
143
-
144
-
145
- header('Location: index.php'); exit();
146
-
147
- } else {
148
-
149
- $error['login'] = 'failed';
150
-
151
- }
152
-
153
- } else {
154
-
155
- $error['login'] = 'blank';
156
-
157
- }
158
-
159
- }
160
-
161
- ?>
162
-
163
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
164
-
165
- <html xmlns="http://www.w3.org/1999/xhtml">
166
-
167
- <head>
168
-
169
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
170
-
171
- <link rel="stylesheet" type="text/css" href="../style.css" />
172
-
173
- <link href="https://fonts.googleapis.com/css?family=Pacifico" rel="stylesheet">
174
-
175
- <title>ログインする</title>
176
-
177
- </head>
178
-
179
-
180
-
181
- <body>
182
-
183
- <div id="wrap">
184
-
185
- <div id="head">
186
-
187
-
188
-
189
- </div>
190
-
191
- <div id="content">
192
-
193
- <div id="lead">
194
-
195
- <p>メールアドレスとパスワードを記入してログインしてください。</p>
196
-
197
- <p>入会手続きがまだの方はこちらからどうぞ。</p>
198
-
199
- <p>&raquo;<a href="join/">入会手続きをする</a></p>
200
-
201
- </div>
202
-
203
- <form action="" method="post">
204
-
205
- <dl>
206
-
207
- <dt>メールアドレス</dt>
208
-
209
- <dd>
210
-
211
- <input type="text" name="email" size="35" maxlength="255" value="<?php echo htmlspecialchars($_POST['email']); ?>" />
212
-
213
- <?php if ($error['login'] == 'blank'): ?>
214
-
215
- <p class="error">* メールアドレスとパスワードをご記入ください</p>
216
-
217
- <?php endif; ?>
218
-
219
- <?php if ($error['login'] == 'failed'): ?>
220
-
221
- <p class="error">* ログインに失敗しました。正しくご記入ください。</p>
222
-
223
- <?php endif; ?>
224
-
225
- </dd>
226
-
227
- <dt>パスワード</dt>
228
-
229
- <dd>
230
-
231
- <input type="password" name="password" size="35" maxlength="255" value="<?php echo htmlspecialchars($_POST['password']); ?>" />
232
-
233
- </dd>
234
-
235
- <dt>ログイン情報の記録</dt>
236
-
237
- <dd>
238
-
239
- <input id="save" type="checkbox" name="save" value="on">
240
-
241
- <label for="save">次回からは自動的にログインする</label>
242
-
243
- </dd>
244
-
245
- </dl>
246
-
247
- <div>
248
-
249
- <input type="submit" value="ログインする" />
250
-
251
- </div>
252
-
253
- </form>
254
-
255
- </div>
256
-
257
-
258
-
259
- </div>
260
-
261
- </div>
262
-
263
-
264
-
265
- </body>
266
-
267
- </html>
87
+ <?php
88
+
89
+ require('dbconnect.php');
90
+
91
+
92
+
93
+ //session_start();
94
+
95
+
96
+
97
+ if ($_COOKIE['email'] != '') {
98
+
99
+ $_POST['email'] = $_COOKIE['email'];
100
+
101
+ $_POST['password'] = $_COOKIE['password'];
102
+
103
+ $_POST['save'] = 'on';
104
+
105
+ }
106
+
107
+
108
+
109
+ if (!empty($_POST)) {
110
+
111
+ // ログインの処理
112
+
113
+ if ($_POST['email'] != '' && $_POST['password'] != '') {
114
+
115
+ $login = $db->prepare('SELECT * FROM members WHERE email=? AND password=?');
116
+
117
+ $login->execute(array(
118
+
119
+ $_POST['email'],
120
+
121
+ sha1($_POST['password'])
122
+
123
+ ));
124
+
125
+ $member = $login->fetch();
126
+
127
+
128
+
129
+ if ($member) {
130
+
131
+ // ログイン成功
132
+
133
+ $_SESSION['id'] = $member['id'];
134
+
135
+ $_SESSION['time'] = time();
136
+
137
+
138
+
139
+ // ログイン情報を記録する
140
+
141
+ if ($_POST['save'] == 'on') {
142
+
143
+ setcookie('email', $_POST['email'], time()+60*60*24*14);
144
+
145
+ setcookie('password', $_POST['password'], time()+60*60*24*14);
146
+
147
+ }
148
+
149
+
150
+
151
+ header('Location: index.php'); exit();
152
+
153
+ } else {
154
+
155
+ $error['login'] = 'failed';
156
+
157
+ }
158
+
159
+ } else {
160
+
161
+ $error['login'] = 'blank';
162
+
163
+ }
164
+
165
+ }
166
+
167
+ ?>
168
+
169
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
170
+
171
+ <html xmlns="http://www.w3.org/1999/xhtml">
172
+
173
+ <head>
174
+
175
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
176
+
177
+ <link rel="stylesheet" type="text/css" href="../style.css" />
178
+
179
+ <link href="https://fonts.googleapis.com/css?family=Pacifico" rel="stylesheet">
180
+
181
+ <title>ログインする</title>
182
+
183
+ </head>
184
+
185
+
186
+
187
+ <body>
188
+
189
+ <div id="wrap">
190
+
191
+ <div id="head">
192
+
193
+
194
+
195
+ </div>
196
+
197
+ <div id="content">
198
+
199
+ <div id="lead">
200
+
201
+ <p>メールアドレスとパスワードを記入してログインしてください。</p>
202
+
203
+ <p>入会手続きがまだの方はこちらからどうぞ。</p>
204
+
205
+ <p>&raquo;<a href="join/">入会手続きをする</a></p>
206
+
207
+ </div>
208
+
209
+ <form action="" method="post">
210
+
211
+ <dl>
212
+
213
+ <dt>メールアドレス</dt>
214
+
215
+ <dd>
216
+
217
+ <input type="text" name="email" size="35" maxlength="255" value="<?php echo htmlspecialchars($_POST['email']); ?>" />
218
+
219
+ <?php if ($error['login'] == 'blank'): ?>
220
+
221
+ <p class="error">* メールアドレスとパスワードをご記入ください</p>
222
+
223
+ <?php endif; ?>
224
+
225
+ <?php if ($error['login'] == 'failed'): ?>
226
+
227
+ <p class="error">* ログインに失敗しました。正しくご記入ください。</p>
228
+
229
+ <?php endif; ?>
230
+
231
+ </dd>
232
+
233
+ <dt>パスワード</dt>
234
+
235
+ <dd>
236
+
237
+ <input type="password" name="password" size="35" maxlength="255" value="<?php echo htmlspecialchars($_POST['password']); ?>" />
238
+
239
+ </dd>
240
+
241
+ <dt>ログイン情報の記録</dt>
242
+
243
+ <dd>
244
+
245
+ <input id="save" type="checkbox" name="save" value="on">
246
+
247
+ <label for="save">次回からは自動的にログインする</label>
248
+
249
+ </dd>
250
+
251
+ </dl>
252
+
253
+ <div>
254
+
255
+ <input type="submit" value="ログインする" />
256
+
257
+ </div>
258
+
259
+ </form>
260
+
261
+ </div>
262
+
263
+
264
+
265
+ </div>
266
+
267
+ </div>
268
+
269
+ <div id="foot">
270
+
271
+ <p style="font-family: 'Pacifico', cursive; font-size:25px; text-align:center;">&copy;2012-2018 Todaylesson Team BLACKBOARD <br>&copy; H2O Space. MYCOM,</p>
272
+
273
+ </div>
274
+
275
+ </body>
276
+
277
+ </html>
268
278
 
269
279
  </div>
270
280