質問編集履歴
1
$errorの初期化、empty()をcount()へ、array_key_exists()の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,7 +18,13 @@
|
|
18
18
|
|
19
19
|
```
|
20
20
|
|
21
|
+
Undefined index: name in が88,89行に
|
22
|
+
|
21
|
-
|
23
|
+
Undefined index: email in が97,100行に
|
24
|
+
|
25
|
+
Undefined index: password in が108,111行に出ます。
|
26
|
+
|
27
|
+
パスワードの入力画面にも「・・・・・・・・・・・・・・・・・・・・」とあるのでエラーが出ていると思われます。
|
22
28
|
|
23
29
|
```
|
24
30
|
|
@@ -280,6 +286,250 @@
|
|
280
286
|
|
281
287
|
|
282
288
|
|
289
|
+
したはアドバイスをいただいて変更したものです。
|
290
|
+
|
291
|
+
### php
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
```ここに言語名を入力
|
296
|
+
|
297
|
+
<head>
|
298
|
+
|
299
|
+
<!-----------Confirmation of input items------------------------------------------------>
|
300
|
+
|
301
|
+
<?php
|
302
|
+
|
303
|
+
require('../dbconnect.php');
|
304
|
+
|
305
|
+
session_start();
|
306
|
+
|
307
|
+
$error =[];
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
if (!empty($_POST)){
|
312
|
+
|
313
|
+
if (array_key_exists($_POST['name']) && $_POST['name'] == '') {
|
314
|
+
|
315
|
+
$error['name'] = 'blank';
|
316
|
+
|
317
|
+
}
|
318
|
+
|
319
|
+
if (array_key_exists($_POST['email']) && $_POST['email'] == '') {
|
320
|
+
|
321
|
+
$error['email'] = 'blank';
|
322
|
+
|
323
|
+
}
|
324
|
+
|
325
|
+
if (array_key_exists($_POST['password']) && strlen($_POST['password']) < 4) {
|
326
|
+
|
327
|
+
$error['password'] = 'length';
|
328
|
+
|
329
|
+
}
|
330
|
+
|
331
|
+
if (array_key_exists($_POST['password']) && $_POST['password'] == '') {
|
332
|
+
|
333
|
+
$error['password'] = 'blank';
|
334
|
+
|
335
|
+
}
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
//---------- Check for duplicate accounts -------------------------------------------------//
|
340
|
+
|
341
|
+
if(empty($error)) {
|
342
|
+
|
343
|
+
$member = $db->prepare('SELECT COUNT(*) AS cnt FROM members WHERE email=?');
|
344
|
+
|
345
|
+
$member->execute(array($_POST['email']));
|
346
|
+
|
347
|
+
$record = $member->fetch();
|
348
|
+
|
349
|
+
if ($record['cnt'] > 0) {
|
350
|
+
|
351
|
+
$error['email'] = 'duplicate';
|
352
|
+
|
353
|
+
}
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
$_SESSION['join'] = $_POST;
|
358
|
+
|
359
|
+
header('Location: check.php');
|
360
|
+
|
361
|
+
exit();
|
362
|
+
|
363
|
+
}
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
if($_REQUEST['action'] == 'rewrite') {
|
368
|
+
|
369
|
+
$_POST = $_SESSION['join'];
|
370
|
+
|
371
|
+
$error['rewrite'] = true;
|
372
|
+
|
373
|
+
}
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
}
|
378
|
+
|
379
|
+
?>
|
380
|
+
|
381
|
+
<!-----------end------------------------------------------------>
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
<meta charset="UTF-8">
|
386
|
+
|
387
|
+
<title></title>
|
388
|
+
|
389
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
390
|
+
|
391
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
392
|
+
|
393
|
+
<meta name="format-detection" content="email=no,telephone=no,address=no">
|
394
|
+
|
395
|
+
<link href="../font/css/open-iconic-bootstrap.css" rel="stylesheet">
|
396
|
+
|
397
|
+
<!-- BootstrapのCSS読み込み -->
|
398
|
+
|
399
|
+
<link href="../css/bootstrap.min.css" rel="stylesheet">
|
400
|
+
|
401
|
+
<!-- jQuery読み込み -->
|
402
|
+
|
403
|
+
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" ></script>
|
404
|
+
|
405
|
+
<!-- BootstrapのJS読み込み -->
|
406
|
+
|
407
|
+
<script src="../js/bootstrap.min.js"></script>
|
408
|
+
|
409
|
+
<!---css------->
|
410
|
+
|
411
|
+
<link rel="stylesheet" href="../css/join.css">
|
412
|
+
|
413
|
+
<link rel="stylesheet" href="../css/common.css">
|
414
|
+
|
415
|
+
<!---Google Material Icons------->
|
416
|
+
|
417
|
+
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
<!-- Required meta tags -->
|
422
|
+
|
423
|
+
<meta charset="utf-8">
|
424
|
+
|
425
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
</head>
|
430
|
+
|
431
|
+
<body>
|
432
|
+
|
433
|
+
<header class="text-center mt-3">
|
434
|
+
|
435
|
+
<img class="head_rogo ml-md-5" src="../images/SVG/rogo.svg">
|
436
|
+
|
437
|
+
<div class="float-right mr-md-3">
|
438
|
+
|
439
|
+
<img class="head_icon mr-2" src="../images/SVG/head_login.svg">
|
440
|
+
|
441
|
+
<img class="head_icon mr-2 mt-1" src="../images/SVG/head_favorite.svg">
|
442
|
+
|
443
|
+
<img class="head_icon mr-2" src="../images/SVG/head_bag.svg">
|
444
|
+
|
445
|
+
</div>
|
446
|
+
|
447
|
+
<div class="border-bottom ml-3 mr-3"></div>
|
448
|
+
|
449
|
+
</header>
|
450
|
+
|
451
|
+
<main>
|
452
|
+
|
453
|
+
<!-----------contents------------------------------------------------------------------------------------------------->
|
454
|
+
|
455
|
+
<div class="container">
|
456
|
+
|
457
|
+
<div class="border-pink f-darkpink mt-4"><img class="title_icon mr-2 mb-2" src="../images/SVG/head_login.svg">アカウント作成</div>
|
458
|
+
|
459
|
+
<form class="f-white" action="" method="post" >
|
460
|
+
|
461
|
+
<div class="form-group w-25 formwidth">
|
462
|
+
|
463
|
+
<label for="inputname">name<span class="required ml-2 fs-8 f-darkpink">必須</span></label>
|
464
|
+
|
465
|
+
<input type="text" name="name" class="form-control" id="inputname"
|
466
|
+
|
467
|
+
value="<?php echo htmlspecialchars($_POST['name'],ENT_QUOTES); ?>"/>
|
468
|
+
|
469
|
+
<?php if ($error['name'] == 'blank' ): ?>
|
470
|
+
|
471
|
+
<p class="error">*名前を入力してください。</p>
|
472
|
+
|
473
|
+
<?php endif; ?>
|
474
|
+
|
475
|
+
</div>
|
476
|
+
|
477
|
+
<div class="form-group w-50 formwidth">
|
478
|
+
|
479
|
+
<label for="exampleInputEmail1">email<span class="required ml-2 fs-8 f-darkpink">必須</span></label>
|
480
|
+
|
481
|
+
<input type="text" name="email" class="form-control" id="exampleInputEmail1"
|
482
|
+
|
483
|
+
value="<?php echo htmlspecialchars($_POST['email'], ENT_QUOTES); ?>"/>
|
484
|
+
|
485
|
+
<?php if ($error['email'] == 'blank'): ?>
|
486
|
+
|
487
|
+
<p class="error">*メールアドレスを入力して下さい</p>
|
488
|
+
|
489
|
+
<?php endif; ?>
|
490
|
+
|
491
|
+
<?php if ($error['email'] == 'duplicate'): ?>
|
492
|
+
|
493
|
+
<p class="error">*指定されたメールアドレスは既に登録されています</p>
|
494
|
+
|
495
|
+
<?php endif; ?>
|
496
|
+
|
497
|
+
</div>
|
498
|
+
|
499
|
+
<div class="form-group w-50 formwidth">
|
500
|
+
|
501
|
+
<label for="exampleInputPassword1">password<span class="required ml-2 fs-8 f-darkpink">必須</span></label>
|
502
|
+
|
503
|
+
<input type="password" name="password" class="form-control" id="exampleInputPassword1"
|
504
|
+
|
505
|
+
value="<?php echo htmlspecialchars($_POST['password'],ENT_QUOTES); ?>"/>
|
506
|
+
|
507
|
+
<?php if ($error['password'] == 'blank'): ?>
|
508
|
+
|
509
|
+
<p class="error">*パスワードを入力してください</p>
|
510
|
+
|
511
|
+
<?php endif; ?>
|
512
|
+
|
513
|
+
<?php if ($error['password'] == 'length'): ?>
|
514
|
+
|
515
|
+
<p class="error">*パスワードは4文字以上で入力してください</p>
|
516
|
+
|
517
|
+
<?php endif; ?>
|
518
|
+
|
519
|
+
</div>
|
520
|
+
|
521
|
+
<div class="text-center pt-5">
|
522
|
+
|
523
|
+
<input type="submit" class="btn bg-pink f-white" value="アカウント作成">
|
524
|
+
|
525
|
+
</div>
|
526
|
+
|
527
|
+
</form>
|
528
|
+
|
529
|
+
|
530
|
+
|
531
|
+
```
|
532
|
+
|
283
533
|
### 試したこと
|
284
534
|
|
285
535
|
|