質問編集履歴
3
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -46,6 +46,7 @@
|
|
46
46
|
|
47
47
|
|
48
48
|
<p><input type="submit" name="sub" id="sub" value="登録する"></p>
|
49
|
+
<?php echo $_SESSION["error"]; ?>
|
49
50
|
|
50
51
|
</form>
|
51
52
|
</body>
|
@@ -90,6 +91,14 @@
|
|
90
91
|
$errors['mail'] = "すでに登録されたデータです。";
|
91
92
|
}
|
92
93
|
}
|
94
|
+
if(isset($errors)){
|
95
|
+
$_SESSION['error'] = $errors;
|
96
|
+
header("Location: registration_mail_form.php");
|
97
|
+
exit();
|
98
|
+
}
|
99
|
+
|
100
|
+
|
101
|
+
|
93
102
|
}
|
94
103
|
}
|
95
104
|
}
|
@@ -111,11 +120,7 @@
|
|
111
120
|
|
112
121
|
<?php if (count($errors) === 0): ?>
|
113
122
|
|
114
|
-
|
123
|
+
|
115
|
-
|
116
|
-
<p>↓このURLが記載されたメールが届きます。</p>
|
117
|
-
<a href="<?=$url?>"><?=$url?></a>
|
118
|
-
|
119
124
|
<?php elseif(count($errors) > 0): ?>
|
120
125
|
|
121
126
|
<?php
|
2
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -13,7 +13,9 @@
|
|
13
13
|
###やりたいこと
|
14
14
|
下記のようなエラー(check.php)にて、エラーが発生した場合、
|
15
15
|
form.phpのページに戻ってエラーを表示したいです。
|
16
|
+
|
16
|
-
|
17
|
+
form.php
|
18
|
+
```php
|
17
19
|
<?php
|
18
20
|
session_start();
|
19
21
|
----省略-----
|
@@ -49,7 +51,9 @@
|
|
49
51
|
</body>
|
50
52
|
</html>
|
51
53
|
```
|
54
|
+
|
52
|
-
|
55
|
+
check.php↓
|
56
|
+
```php
|
53
57
|
<?php
|
54
58
|
session_start();
|
55
59
|
|
1
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -13,8 +13,57 @@
|
|
13
13
|
###やりたいこと
|
14
14
|
下記のようなエラー(check.php)にて、エラーが発生した場合、
|
15
15
|
form.phpのページに戻ってエラーを表示したいです。
|
16
|
+
```form.php
|
17
|
+
<?php
|
18
|
+
session_start();
|
19
|
+
----省略-----
|
20
|
+
?>
|
21
|
+
|
22
|
+
<!DOCTYPE html>
|
23
|
+
<html>
|
24
|
+
<head>
|
25
|
+
-----省略-----
|
26
|
+
</head>
|
27
|
+
<body>
|
28
|
+
|
29
|
+
<script type="text/javascript">
|
30
|
+
--JS省略----
|
31
|
+
</script>
|
32
|
+
|
33
|
+
<form method="post" name="form1" id="form1" action="check.php">
|
34
|
+
|
35
|
+
<dt><span class="req">メールアドレス 必須</span></dt>
|
36
|
+
<input type="text" id="mail" name="mail">
|
37
|
+
<p><input type="hidden" name="token" value="<?=$token?>"></p>
|
38
|
+
<span id="mail_error" class="error_m"></span><br>
|
39
|
+
|
40
|
+
|
41
|
+
<dt><span class="req">メールアドレス(確認用)必須</span></dt>
|
42
|
+
<p><input type="text" id="mail_2" name="mail_2"></p>
|
43
|
+
<span id="mail_error_2" class="error_m"></span><br>
|
44
|
+
|
45
|
+
|
46
|
+
<p><input type="submit" name="sub" id="sub" value="登録する"></p>
|
47
|
+
|
48
|
+
</form>
|
49
|
+
</body>
|
50
|
+
</html>
|
51
|
+
```
|
16
52
|
```check.php
|
53
|
+
<?php
|
54
|
+
session_start();
|
17
55
|
|
56
|
+
header("Content-type: text/html;unix_socket=/tmp/mysql.sock;charset=utf-8");
|
57
|
+
|
58
|
+
|
59
|
+
//データベース接続
|
60
|
+
require_once("db.php");
|
61
|
+
$dbh = db_connect();
|
62
|
+
|
63
|
+
|
64
|
+
//エラーメッセージの初期化
|
65
|
+
$errors = array();
|
66
|
+
|
18
67
|
if(empty($_POST)) {
|
19
68
|
header("Location: registration_mail_form.php");
|
20
69
|
exit();
|
@@ -37,6 +86,46 @@
|
|
37
86
|
$errors['mail'] = "すでに登録されたデータです。";
|
38
87
|
}
|
39
88
|
}
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
------トークン確認省略
|
94
|
+
|
95
|
+
$body = <<< EOM
|
96
|
+
仮会員登録完了
|
97
|
+
-----------会員登録完了メール省略
|
98
|
+
|
99
|
+
<!DOCTYPE html>
|
100
|
+
<html>
|
101
|
+
<head>
|
102
|
+
<title>メール確認画面</title>
|
103
|
+
<meta charset="utf-8">
|
104
|
+
</head>
|
105
|
+
<body>
|
106
|
+
<h1>メール確認画面</h1>
|
107
|
+
|
108
|
+
<?php if (count($errors) === 0): ?>
|
109
|
+
|
110
|
+
<p><?=$message?></p>
|
111
|
+
|
112
|
+
<p>↓このURLが記載されたメールが届きます。</p>
|
113
|
+
<a href="<?=$url?>"><?=$url?></a>
|
114
|
+
|
115
|
+
<?php elseif(count($errors) > 0): ?>
|
116
|
+
|
117
|
+
<?php
|
118
|
+
foreach($errors as $value){
|
119
|
+
echo "<p>".$value."</p>";
|
120
|
+
}
|
121
|
+
?>
|
122
|
+
|
123
|
+
<input type="button" value="戻る" onClick="history.back()">
|
124
|
+
|
125
|
+
<?php endif; ?>
|
126
|
+
|
127
|
+
</body>
|
128
|
+
</html>
|
40
129
|
```
|
41
130
|
|
42
131
|
###質問点
|