質問編集履歴

1

新規登録フォームと確認フォームのコードを追加しました。

2017/08/18 06:18

投稿

dog57
dog57

スコア131

test CHANGED
File without changes
test CHANGED
@@ -36,6 +36,464 @@
36
36
 
37
37
  ###該当のソースコード
38
38
 
39
+
40
+
41
+ 新規登録フォーム
42
+
43
+ ```HTML
44
+
45
+ <!DOCTYPE html>
46
+
47
+ <html lang=“ja”>
48
+
49
+ <head>
50
+
51
+ <meta charset="UTF-8">
52
+
53
+ <title>My Web Site</title>
54
+
55
+ <link rel="stylesheet" href="style2.css">
56
+
57
+
58
+
59
+ </head>
60
+
61
+ <body>
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+ <header>
70
+
71
+ <div class="header-left">
72
+
73
+ <img class="logo" src="https://www.fastpic.jp/images.php?file=3519571152.jpg" alt="ロゴ画像">
74
+
75
+ </div>
76
+
77
+
78
+
79
+ </header>
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+ <div class="main">
88
+
89
+ <ol class="topic-path">
90
+
91
+ <li><a href="#">一覧へ</a> > </li>
92
+
93
+ <li>登録</li>
94
+
95
+ </ol>
96
+
97
+
98
+
99
+
100
+
101
+ <div class="container">
102
+
103
+ <h1>登録</h1>
104
+
105
+ <hr>
106
+
107
+
108
+
109
+
110
+
111
+ <form action="confirm.php" method="post">
112
+
113
+ <table border="0" class="touroku">
114
+
115
+
116
+
117
+ <tr>
118
+
119
+ <td align="right"> 氏名: </td>
120
+
121
+ <td><input type="text" size="25" name="yourname"></td>
122
+
123
+ </tr>
124
+
125
+
126
+
127
+ <tr>
128
+
129
+ <td align="right"> 都道府県: </td>
130
+
131
+ <td> <select name="live">
132
+
133
+ <option value="選択してください">選択してください</option>
134
+
135
+ <option value="東京">東京</option>
136
+
137
+ <option value="大阪">大阪</option>
138
+
139
+ <option value="名古屋">名古屋</option>
140
+
141
+ </select>
142
+
143
+ </td>
144
+
145
+ </tr>
146
+
147
+
148
+
149
+ <tr>
150
+
151
+ <td align="right"> 電話番号: </td>
152
+
153
+ <td><input type="text" size="30" name="tel"></td>
154
+
155
+ </tr>
156
+
157
+
158
+
159
+ <tr>
160
+
161
+ <td align="right"> 性別: </td>
162
+
163
+ <td><label><input type="radio" name="gender" value="男性">男性</label>
164
+
165
+ <label><input type="radio" name="gender" value="女性">女性</label>
166
+
167
+ <label><input type="radio" name="gender" value="未回答">未回答</label>
168
+
169
+ </td>
170
+
171
+ </tr>
172
+
173
+
174
+
175
+ <tr>
176
+
177
+ <td align="right"> 趣味:</td>
178
+
179
+ <td>
180
+
181
+ <label><input type="checkbox" value="趣味" name="shumi[1]">映画</label>
182
+
183
+ <label><input type="checkbox" value="趣味" name="shumi[2]">グルメ</label>
184
+
185
+ <label><input type="checkbox" value="趣味" name="shumi[3]">スポーツ<br></label>
186
+
187
+ <label><input type="checkbox" value="趣味" name="shumi[4]">読書</label>
188
+
189
+ <label><input type="checkbox" value="趣味" name="shumi[5]">ファッション</label>
190
+
191
+ <label><input type="checkbox" value="趣味" name="shumi[6]">アニメ</label>
192
+
193
+ </td>
194
+
195
+ </tr>
196
+
197
+
198
+
199
+ <tr>
200
+
201
+ <td align="right"> 備考欄: </td>
202
+
203
+ <td><textarea name="kanso" rows="3" cols="40">感想</textarea></td>
204
+
205
+ </tr>
206
+
207
+
208
+
209
+ </table>
210
+
211
+
212
+
213
+ <a href="index.html"><input type="button" value="一覧へ戻る"></a>
214
+
215
+ <a href="confirm.php"><input type="submit" value="確認する"></a>
216
+
217
+
218
+
219
+
220
+
221
+
222
+
223
+ </div>
224
+
225
+ </div>
226
+
227
+ </div>
228
+
229
+
230
+
231
+ <footer>
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+ </footer>
242
+
243
+
244
+
245
+ </div>
246
+
247
+
248
+
249
+
250
+
251
+ </body>
252
+
253
+ </html>
254
+
255
+ ```
256
+
257
+
258
+
259
+ 確認フォーム
260
+
261
+ ```php
262
+
263
+ <?php
264
+
265
+ // $_POSTで受け取る
266
+
267
+ $yourname = $_POST["yourname"];
268
+
269
+ $live = $_POST["live"];
270
+
271
+ $tel = $_POST["tel"];
272
+
273
+ $gender = $_POST["gender"];
274
+
275
+ $shumi = $_POST["shumi"];
276
+
277
+ $kanso = $_POST["kanso"];
278
+
279
+ ?>
280
+
281
+
282
+
283
+
284
+
285
+
286
+
287
+ <!DOCTYPE html>
288
+
289
+ <html>
290
+
291
+ <head>
292
+
293
+ <meta charset="utf-8" />
294
+
295
+ <title>My Web Site</title>
296
+
297
+ <link rel="stylesheet" href="style3.css">
298
+
299
+
300
+
301
+ </head>
302
+
303
+ <body>
304
+
305
+
306
+
307
+ <div class="main">
308
+
309
+ <div class="form-title"></div>
310
+
311
+ <h2>確認画面</h2>
312
+
313
+
314
+
315
+
316
+
317
+ <table border="0" class="form-item">
318
+
319
+ <tr>
320
+
321
+ <td align="right" class="form-item"> 氏名 : </td>
322
+
323
+ <td align="left"><?php echo $yourname ?></td>
324
+
325
+ </tr>
326
+
327
+
328
+
329
+ <tr>
330
+
331
+ <td align="right" class="form-item"> 都道府県 : </td>
332
+
333
+ <td align="left"><?php echo $live ?></td>
334
+
335
+ </tr>
336
+
337
+
338
+
339
+ <tr>
340
+
341
+ <td align="right" class="form-item"> 電話番号 : </td>
342
+
343
+ <td align="left"><?php echo $tel ?></td>
344
+
345
+ </tr>
346
+
347
+
348
+
349
+ <tr>
350
+
351
+ <td align="right" class="form-item"> 性別 : </td>
352
+
353
+ <td align="left">
354
+
355
+ <?php
356
+
357
+ if (isset($_POST["gender"])) {//もしPOSTに[genderがあれば
358
+
359
+ if ($_POST["gender"] == "男性") { //もし男性なら
360
+
361
+ echo "男性";
362
+
363
+ }
364
+
365
+ elseif ($_POST["gender"] == "女性") { //女性なら
366
+
367
+ echo "女性";
368
+
369
+ }
370
+
371
+ elseif ($_POST["gender"] == "未回答") { //未回答なら
372
+
373
+ echo "未回答";
374
+
375
+ }
376
+
377
+ else {
378
+
379
+ echo "どれかチェックしてから[送信]ボタンを押してください。";
380
+
381
+ }
382
+
383
+ }
384
+
385
+ ?>
386
+
387
+ </td>
388
+
389
+ </tr>
390
+
391
+
392
+
393
+ <tr>
394
+
395
+ <td align="right" class="form-item"> 趣味 : </td>
396
+
397
+ <td align="left">
398
+
399
+ <?php
400
+
401
+ if (isset($_POST["shumi"])) { //チェックされていれば
402
+
403
+ $shumi = $_POST["shumi"]; //変数 $shumi に格納
404
+
405
+ }
406
+
407
+ if (isset($shumi[1])) {
408
+
409
+ echo " 映画";
410
+
411
+ }
412
+
413
+ if (isset($shumi[2])) {
414
+
415
+ echo " グルメ";
416
+
417
+ }
418
+
419
+ if (isset($shumi[3])) {
420
+
421
+ echo " スポーツ";
422
+
423
+ }
424
+
425
+ if (isset($shumi[4])) {
426
+
427
+ echo " 読書";
428
+
429
+ }
430
+
431
+ if (isset($shumi[5])) {
432
+
433
+ echo " ファッション";
434
+
435
+ }
436
+
437
+ if (isset($shumi[6])) {
438
+
439
+ echo " アニメ";
440
+
441
+ }
442
+
443
+ else {
444
+
445
+ echo "";
446
+
447
+ }
448
+
449
+ ?>
450
+
451
+ </td>
452
+
453
+ </tr>
454
+
455
+
456
+
457
+ <tr>
458
+
459
+ <td align="right" class="form-item"> 備考欄 : </td>
460
+
461
+ <td align="left"><?php echo $kanso ?></td>
462
+
463
+ </tr>
464
+
465
+ </table>
466
+
467
+
468
+
469
+
470
+
471
+ <a href="index2.html"><input type="button" name="back" width="30px" value="戻る"></a>
472
+
473
+ <a href="registration.php"><input type="submit" name="button1" width="30px" value="送信"></p></a>
474
+
475
+
476
+
477
+
478
+
479
+ </div>
480
+
481
+ </div>
482
+
483
+
484
+
485
+
486
+
487
+ </body>
488
+
489
+ </html>
490
+
491
+
492
+
493
+ ```
494
+
495
+
496
+
39
497
  ```PHP
40
498
 
41
499
  (index.php データーベースに繋げるための専用のファイル)