質問編集履歴

3

修正

2019/03/08 07:17

投稿

Roo
Roo

スコア55

test CHANGED
File without changes
test CHANGED
@@ -94,6 +94,8 @@
94
94
 
95
95
  <p><input type="submit" name="sub" id="sub" value="登録する"></p>
96
96
 
97
+ <?php echo $_SESSION["error"]; ?>
98
+
97
99
 
98
100
 
99
101
  </form>
@@ -182,6 +184,22 @@
182
184
 
183
185
  }
184
186
 
187
+ if(isset($errors)){
188
+
189
+ $_SESSION['error'] = $errors;
190
+
191
+ header("Location: registration_mail_form.php");
192
+
193
+ exit();
194
+
195
+ }
196
+
197
+
198
+
199
+
200
+
201
+
202
+
185
203
  }
186
204
 
187
205
  }
@@ -224,15 +242,7 @@
224
242
 
225
243
 
226
244
 
227
- <p><?=$message?></p>
245
+
228
-
229
-
230
-
231
- <p>↓このURLが記載されたメールが届きます。</p>
232
-
233
- <a href="<?=$url?>"><?=$url?></a>
234
-
235
-
236
246
 
237
247
  <?php elseif(count($errors) > 0): ?>
238
248
 

2

修正

2019/03/08 07:17

投稿

Roo
Roo

スコア55

test CHANGED
File without changes
test CHANGED
@@ -28,7 +28,11 @@
28
28
 
29
29
  form.phpのページに戻ってエラーを表示したいです。
30
30
 
31
+
32
+
31
- ```form.php
33
+ form.php
34
+
35
+ ```php
32
36
 
33
37
  <?php
34
38
 
@@ -100,7 +104,11 @@
100
104
 
101
105
  ```
102
106
 
107
+
108
+
103
- ```check.php
109
+ check.php
110
+
111
+ ```php
104
112
 
105
113
  <?php
106
114
 

1

修正

2019/03/08 05:26

投稿

Roo
Roo

スコア55

test CHANGED
File without changes
test CHANGED
@@ -28,8 +28,106 @@
28
28
 
29
29
  form.phpのページに戻ってエラーを表示したいです。
30
30
 
31
+ ```form.php
32
+
33
+ <?php
34
+
35
+ session_start();
36
+
37
+ ----省略-----
38
+
39
+ ?>
40
+
41
+
42
+
43
+ <!DOCTYPE html>
44
+
45
+ <html>
46
+
47
+ <head>
48
+
49
+ -----省略-----
50
+
51
+ </head>
52
+
53
+ <body>
54
+
55
+
56
+
57
+ <script type="text/javascript">
58
+
59
+ --JS省略----
60
+
61
+ </script>
62
+
63
+
64
+
65
+ <form method="post" name="form1" id="form1" action="check.php">
66
+
67
+
68
+
69
+ <dt><span class="req">メールアドレス 必須</span></dt>
70
+
71
+ <input type="text" id="mail" name="mail">
72
+
73
+ <p><input type="hidden" name="token" value="<?=$token?>"></p>
74
+
75
+ <span id="mail_error" class="error_m"></span><br>
76
+
77
+
78
+
79
+
80
+
81
+ <dt><span class="req">メールアドレス(確認用)必須</span></dt>
82
+
83
+ <p><input type="text" id="mail_2" name="mail_2"></p>
84
+
85
+ <span id="mail_error_2" class="error_m"></span><br>
86
+
87
+
88
+
89
+
90
+
91
+ <p><input type="submit" name="sub" id="sub" value="登録する"></p>
92
+
93
+
94
+
95
+ </form>
96
+
97
+ </body>
98
+
99
+ </html>
100
+
101
+ ```
102
+
31
103
  ```check.php
32
104
 
105
+ <?php
106
+
107
+ session_start();
108
+
109
+
110
+
111
+ header("Content-type: text/html;unix_socket=/tmp/mysql.sock;charset=utf-8");
112
+
113
+
114
+
115
+
116
+
117
+ //データベース接続
118
+
119
+ require_once("db.php");
120
+
121
+ $dbh = db_connect();
122
+
123
+
124
+
125
+
126
+
127
+ //エラーメッセージの初期化
128
+
129
+ $errors = array();
130
+
33
131
 
34
132
 
35
133
  if(empty($_POST)) {
@@ -76,6 +174,86 @@
76
174
 
77
175
  }
78
176
 
177
+ }
178
+
179
+ }
180
+
181
+ }
182
+
183
+
184
+
185
+ ------トークン確認省略
186
+
187
+
188
+
189
+ $body = <<< EOM
190
+
191
+ 仮会員登録完了
192
+
193
+ -----------会員登録完了メール省略
194
+
195
+
196
+
197
+ <!DOCTYPE html>
198
+
199
+ <html>
200
+
201
+ <head>
202
+
203
+ <title>メール確認画面</title>
204
+
205
+ <meta charset="utf-8">
206
+
207
+ </head>
208
+
209
+ <body>
210
+
211
+ <h1>メール確認画面</h1>
212
+
213
+
214
+
215
+ <?php if (count($errors) === 0): ?>
216
+
217
+
218
+
219
+ <p><?=$message?></p>
220
+
221
+
222
+
223
+ <p>↓このURLが記載されたメールが届きます。</p>
224
+
225
+ <a href="<?=$url?>"><?=$url?></a>
226
+
227
+
228
+
229
+ <?php elseif(count($errors) > 0): ?>
230
+
231
+
232
+
233
+ <?php
234
+
235
+ foreach($errors as $value){
236
+
237
+ echo "<p>".$value."</p>";
238
+
239
+ }
240
+
241
+ ?>
242
+
243
+
244
+
245
+ <input type="button" value="戻る" onClick="history.back()">
246
+
247
+
248
+
249
+ <?php endif; ?>
250
+
251
+
252
+
253
+ </body>
254
+
255
+ </html>
256
+
79
257
  ```
80
258
 
81
259