質問編集履歴
6
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,10 +6,24 @@
|
|
6
6
|
|
7
7
|
### 該当のソースコード
|
8
8
|
|
9
|
-
|
9
|
+
check.php
|
10
10
|
|
11
11
|
```PHP
|
12
12
|
|
13
|
+
<?php
|
14
|
+
|
15
|
+
session_start();
|
16
|
+
|
17
|
+
require('dbconnect.php');
|
18
|
+
|
19
|
+
if(!isset($_SESSION['join'])){
|
20
|
+
|
21
|
+
header('Location: index.php');
|
22
|
+
|
23
|
+
exit();
|
24
|
+
|
25
|
+
}
|
26
|
+
|
13
27
|
if(!empty($_POST)){
|
14
28
|
|
15
29
|
|
@@ -136,7 +150,7 @@
|
|
136
150
|
|
137
151
|
```
|
138
152
|
|
139
|
-
|
153
|
+
index.php
|
140
154
|
|
141
155
|
```php
|
142
156
|
|
@@ -332,6 +346,32 @@
|
|
332
346
|
|
333
347
|
```
|
334
348
|
|
349
|
+
dbconnect.php
|
350
|
+
|
351
|
+
```PHP
|
352
|
+
|
353
|
+
<?php
|
354
|
+
|
355
|
+
try{
|
356
|
+
|
357
|
+
$db = new PDO('mysql:dbname = mini_bbs;host=127.0.0.1;charset=utf8', 'root', 'root' );
|
358
|
+
|
359
|
+
}catch(PDOException $e){
|
360
|
+
|
361
|
+
print('db接続エラー' . $e->getMessage());
|
362
|
+
|
363
|
+
}
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
?>
|
370
|
+
|
371
|
+
```
|
372
|
+
|
373
|
+
|
374
|
+
|
335
375
|
### 試したこと
|
336
376
|
|
337
|
-
実際にthanks.phpへのページ遷移は成功、データベース接続も成功していることから、
|
377
|
+
実際にthanks.phpへのページ遷移は成功、データベース接続も成功していることから、コード内に至らぬ点があると判断しています。くまなく確認していますが、依然として状況は変わらぬままです。
|
5
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
### 正常に情報をデータベースに入力したい
|
2
2
|
|
3
|
-
phpファイルでの作業中に、
|
3
|
+
phpファイルでの作業中に、データベースのテーブルの中のレコードが作られないという状況になりました。
|
4
4
|
|
5
5
|
表記法の誤った点をご指摘いただきたいです。
|
6
6
|
|
4
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -136,9 +136,199 @@
|
|
136
136
|
|
137
137
|
```
|
138
138
|
|
139
|
+
|
140
|
+
|
139
141
|
```php
|
140
142
|
|
143
|
+
<?php
|
144
|
+
|
145
|
+
session_start();
|
146
|
+
|
147
|
+
if(!empty($_POST)){
|
148
|
+
|
149
|
+
if($_POST['name'] === '' ){
|
150
|
+
|
151
|
+
$error['name'] = 'blank';
|
152
|
+
|
153
|
+
}
|
154
|
+
|
155
|
+
if($_POST['email'] === '' ){
|
156
|
+
|
157
|
+
$error['email'] = 'blank';
|
158
|
+
|
159
|
+
}
|
160
|
+
|
161
|
+
if(strlen($_POST['password']) < 4){
|
162
|
+
|
163
|
+
$error['password'] = 'length';
|
164
|
+
|
165
|
+
}
|
166
|
+
|
167
|
+
if($_POST['password'] === '' ){
|
168
|
+
|
169
|
+
$error['password'] = 'blank';
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
$filename = $_FILES['image']['name'];
|
174
|
+
|
175
|
+
if(!empty($filename)){
|
176
|
+
|
177
|
+
$ext = substr($filename,-3);
|
178
|
+
|
179
|
+
if($ext != 'png' && $ext != 'jpeg' && $ext != 'gif'){
|
180
|
+
|
181
|
+
$error['image'] = 'type';
|
182
|
+
|
183
|
+
}
|
184
|
+
|
185
|
+
}
|
186
|
+
|
187
|
+
if(empty($error)){
|
188
|
+
|
189
|
+
// ファイル名を指定
|
190
|
+
|
191
|
+
$image = date('YmdHis') . $_FILES['image']['name'];
|
192
|
+
|
193
|
+
move_uploaded_file($_FILES['image']['tmp_name'],"../member_picture/" . $image);
|
194
|
+
|
195
|
+
$_SESSION['join'] = $_POST;
|
196
|
+
|
197
|
+
$_SESSION['join']['image'] = $image;
|
198
|
+
|
199
|
+
header('Location: check.php');
|
200
|
+
|
201
|
+
exit();
|
202
|
+
|
203
|
+
}
|
204
|
+
|
205
|
+
}
|
206
|
+
|
207
|
+
if($_REQUEST['action'] == 'rewrite'){
|
208
|
+
|
209
|
+
$_POST = $_SESSION['join'];
|
210
|
+
|
211
|
+
}
|
212
|
+
|
141
|
-
|
213
|
+
?>
|
214
|
+
|
215
|
+
<!DOCTYPE html>
|
216
|
+
|
217
|
+
<html lang="ja">
|
218
|
+
|
219
|
+
<head>
|
220
|
+
|
221
|
+
<meta charset="UTF-8">
|
222
|
+
|
223
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
224
|
+
|
225
|
+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
226
|
+
|
227
|
+
<title>会員登録</title>
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
<link rel="stylesheet" href="../style.css" />
|
232
|
+
|
233
|
+
</head>
|
234
|
+
|
235
|
+
<body>
|
236
|
+
|
237
|
+
<div id="wrap">
|
238
|
+
|
239
|
+
<div id="head">
|
240
|
+
|
241
|
+
<h1>会員登録</h1>
|
242
|
+
|
243
|
+
</div>
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
<div id="content">
|
248
|
+
|
249
|
+
<p>次のフォームに必要事項をご記入ください。</p>
|
250
|
+
|
251
|
+
<form action="" method="post" enctype="multipart/form-data">
|
252
|
+
|
253
|
+
<!-- foem action=""であっても自身のリンクにサーバーを介して通信している -->
|
254
|
+
|
255
|
+
<dl>
|
256
|
+
|
257
|
+
<dt>ニックネーム<span class="required">必須</span></dt>
|
258
|
+
|
259
|
+
<dd>
|
260
|
+
|
261
|
+
<input type="text" name="name" size="35" maxlength="255" value="<?php print(htmlspecialchars($_POST['name'], ENT_QUOTES));?>" />
|
262
|
+
|
263
|
+
<?php if ($error['name'] === 'blank'): ?>
|
264
|
+
|
265
|
+
<p class= "error">ニックネームを入力してください</p>
|
266
|
+
|
267
|
+
<?php endif;?>
|
268
|
+
|
269
|
+
</dd>
|
270
|
+
|
271
|
+
<dt>メールアドレス<span class="required">必須</span></dt>
|
272
|
+
|
273
|
+
<dd>
|
274
|
+
|
275
|
+
<input type="text" name="email" size="35" maxlength="255" value="" />
|
276
|
+
|
277
|
+
<?php if ($error['email'] === 'blank'): ?>
|
278
|
+
|
279
|
+
<p class= "error">メールアドレスを入力してください</p>
|
280
|
+
|
281
|
+
<?php endif;?>
|
282
|
+
|
283
|
+
</dd>
|
284
|
+
|
285
|
+
<dt>パスワード<span class="required">必須</span></dt>
|
286
|
+
|
287
|
+
<dd>
|
288
|
+
|
289
|
+
<input type="password" name="password" size="10" maxlength="20" value="" />
|
290
|
+
|
291
|
+
<?php if ($error['password'] === 'length'): ?>
|
292
|
+
|
293
|
+
<p class= "error">4文字以上で入力してください</p>
|
294
|
+
|
295
|
+
<?php endif;?>
|
296
|
+
|
297
|
+
<?php if ($error['password'] === 'blank'): ?>
|
298
|
+
|
299
|
+
<p class= "error">パスワードを入力してください</p>
|
300
|
+
|
301
|
+
<?php endif;?>
|
302
|
+
|
303
|
+
</dd>
|
304
|
+
|
305
|
+
<dt>写真など</dt>
|
306
|
+
|
307
|
+
<dd>
|
308
|
+
|
309
|
+
<input type="file" name="image" size="35" value="test" />
|
310
|
+
|
311
|
+
<?php if($error['image'] === 'type'):?>
|
312
|
+
|
313
|
+
<p class = 'error'>末尾がpng,jpeg,gifのファイルをアップロードしてください</p>
|
314
|
+
|
315
|
+
<?php endif;?>
|
316
|
+
|
317
|
+
</dd>
|
318
|
+
|
319
|
+
</dl>
|
320
|
+
|
321
|
+
<div><input type="submit" value="入力内容を確認する" /></div>
|
322
|
+
|
323
|
+
</form>
|
324
|
+
|
325
|
+
</div>
|
326
|
+
|
327
|
+
</body>
|
328
|
+
|
329
|
+
</html>
|
330
|
+
|
331
|
+
|
142
332
|
|
143
333
|
```
|
144
334
|
|
3
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -38,9 +38,109 @@
|
|
38
38
|
|
39
39
|
}
|
40
40
|
|
41
|
+
?>
|
42
|
+
|
43
|
+
<!DOCTYPE html>
|
44
|
+
|
45
|
+
<html lang="ja">
|
46
|
+
|
47
|
+
<head>
|
48
|
+
|
49
|
+
<meta charset="UTF-8">
|
50
|
+
|
51
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
52
|
+
|
53
|
+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
54
|
+
|
55
|
+
<title>会員登録</title>
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
<link rel="stylesheet" href="../style.css" />
|
60
|
+
|
61
|
+
</head>
|
62
|
+
|
63
|
+
<body>
|
64
|
+
|
65
|
+
<div id="wrap">
|
66
|
+
|
67
|
+
<div id="head">
|
68
|
+
|
69
|
+
<h1>会員登録</h1>
|
70
|
+
|
71
|
+
</div>
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
<div id="content">
|
76
|
+
|
77
|
+
<p>記入した内容を確認して、「登録する」ボタンをクリックしてください</p>
|
78
|
+
|
79
|
+
<form action="" method="post">
|
80
|
+
|
81
|
+
<input type="hidden" name="action" value="submit" />
|
82
|
+
|
83
|
+
<dl>
|
84
|
+
|
85
|
+
<dt>ニックネーム</dt>
|
86
|
+
|
87
|
+
<dd>
|
88
|
+
|
89
|
+
<?php print(htmlspecialchars($_SESSION['join']['name'], ENT_QUOTES));?>
|
90
|
+
|
91
|
+
</dd>
|
92
|
+
|
93
|
+
<dt>メールアドレス</dt>
|
94
|
+
|
95
|
+
<dd>
|
96
|
+
|
97
|
+
<?php print(htmlspecialchars($_SESSION['join']['email'], ENT_QUOTES));?>
|
98
|
+
|
99
|
+
</dd>
|
100
|
+
|
101
|
+
<dt>パスワード</dt>
|
102
|
+
|
103
|
+
<dd>
|
104
|
+
|
105
|
+
【表示されません】
|
106
|
+
|
107
|
+
</dd>
|
108
|
+
|
109
|
+
<dt>写真など</dt>
|
110
|
+
|
111
|
+
<dd>]
|
112
|
+
|
113
|
+
<?php if($_SESSION['join']['image'] !== ''):?>
|
114
|
+
|
115
|
+
<img src = "../member_picture/<?php print(htmlspecialchars($_SESSION['join']['image'],ENT_QUOTES)); ?>"
|
116
|
+
|
117
|
+
<?php endif;?>
|
118
|
+
|
119
|
+
</dd>
|
120
|
+
|
121
|
+
</dl>
|
122
|
+
|
123
|
+
<div><a href="index.php?action=rewrite">« 書き直す</a> | <input type="submit" value="登録する" /></div>
|
124
|
+
|
125
|
+
</form>
|
126
|
+
|
127
|
+
</div>
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
</div>
|
132
|
+
|
133
|
+
</body>
|
134
|
+
|
135
|
+
</html>
|
136
|
+
|
41
137
|
```
|
42
138
|
|
139
|
+
```php
|
43
140
|
|
141
|
+
コード
|
142
|
+
|
143
|
+
```
|
44
144
|
|
45
145
|
### 試したこと
|
46
146
|
|
2
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
### 正常に情報をデータベースに入力したい
|
2
2
|
|
3
3
|
phpファイルでの作業中に、うまく情報をデータベースに入力できなくなりました。
|
4
|
+
|
5
|
+
表記法の誤った点をご指摘いただきたいです。
|
4
6
|
|
5
7
|
### 該当のソースコード
|
6
8
|
|
1
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -42,6 +42,4 @@
|
|
42
42
|
|
43
43
|
### 試したこと
|
44
44
|
|
45
|
-
実際にページ遷移は成功、データベース接続も成功していることから、このコード内に至らぬ点があると判断しています。
|
45
|
+
実際にthanks.phpへのページ遷移は成功、データベース接続も成功していることから、このコード内に至らぬ点があると判断しています。くまなく確認していますが、依然として状況は変わらぬままです。
|
46
|
-
|
47
|
-
くまなく確認していますが、依然として状況は変わらぬままです。
|