質問編集履歴

1

Markdown記述とindex.phpを追加しました。よろしくお願いします。

2019/08/07 01:47

投稿

orchis_mary
orchis_mary

スコア10

test CHANGED
File without changes
test CHANGED
@@ -40,20 +40,120 @@
40
40
 
41
41
 
42
42
 
43
-
44
-
45
-
46
-
47
- confirm.php
43
+ ### index.php
44
+
45
+ ```php
48
46
 
49
47
  <?php
50
48
 
51
49
  session_start();
52
50
 
51
+ $errors = $_SESSION['errors'];
52
+
53
+ unset($_SESSION['errors']);
54
+
55
+ $name = $_SESSION['name'];
56
+
57
+ unset($_SESSION['name']);
58
+
59
+ $email = $_SESSION['email'];
60
+
61
+ unset($_SESSION['email']);
62
+
63
+ $content = $_SESSION['content'];
64
+
65
+ unset($_SESSION['content']);
66
+
67
+ ?>
68
+
69
+ <!DOCTYPE html>
70
+
71
+ <html>
72
+
73
+ <head~/head>
74
+
75
+ <body>
76
+
77
+ <form action="php/confirm.php" method="post" class="contact_form" id="contact_form">
78
+
79
+ <div class="wrap">
80
+
81
+ <input class="contact__name-form" id="name" type="text" placeholder="お名前" name="name" value="<?= htmlspecialchars($name); ?>">
82
+
83
+ <?php if (!empty($errors['name'])): ?>
84
+
85
+ <?php foreach($errors['name'] as $error): ?>
86
+
87
+ <p class="contact__error"><?= htmlspecialchars($error); ?></p>
88
+
89
+ <?php endforeach ?>
90
+
91
+ <?php endif; ?>
92
+
93
+ </div>
94
+
95
+ <div class="wrap">
96
+
97
+ <input class="contact__email-form" id="email" type="text" placeholder="メールアドレス" name="email" value="<?= htmlspecialchars($email); ?>">
98
+
99
+ <?php if (!empty($errors['email'])): ?>
100
+
101
+ <?php foreach ($errors['email'] as $error): ?>
102
+
103
+ <p class="contact__error"><?php echo htmlspecialchars($error); ?></p>
104
+
105
+ <?php endforeach ?>
106
+
107
+ <?php endif; ?>
108
+
109
+ </div>
110
+
111
+ <div class="contact__content">
112
+
113
+ <textarea name="content" class="content" rows="5" cols="100" class="contact__content-form" placeholder="お問い合わせ内容 ※1000文字以内">
114
+
115
+ <?php echo htmlspecialchars($content); ?>
116
+
117
+ </textarea>
118
+
119
+ <?php if (!empty($errors['content'])): ?>
120
+
121
+ <?php foreach ($errors['content'] as $error): ?>
122
+
123
+ <p class="contact__error"><?php echo htmlspecialchars($error); ?></p>
124
+
125
+ <?php endforeach ?>
126
+
127
+ <?php endif; ?>
128
+
129
+ </div>
130
+
131
+ <div class="contact__action-btn">
132
+
133
+ <button class="contact_btn" type="submit">お問い合わせ確認画面へ</button>
134
+
135
+ </div>
136
+
137
+ </form>
138
+
139
+ </body>
140
+
141
+ </html>
142
+
143
+ ```
144
+
145
+
146
+
147
+ ### confirm.php
148
+
149
+ ```php
150
+
151
+ <?php
152
+
153
+ session_start();
154
+
53
155
  require_once 'ContactValidator.php';
54
156
 
55
-
56
-
57
157
  if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
58
158
 
59
159
  header('HTTP', true, 400);
@@ -68,8 +168,6 @@
68
168
 
69
169
  $_SESSION['content'] = $_POST['content'];
70
170
 
71
-
72
-
73
171
  $validator = new ContactValidator($_POST);
74
172
 
75
173
  $errors = $validator->validate();
@@ -88,30 +186,24 @@
88
186
 
89
187
  ?>
90
188
 
91
-
189
+ ```
92
-
190
+
93
- complete.php
191
+ ### complete.php
192
+
94
-
193
+ ```php
95
-
96
194
 
97
195
  <?php
98
196
 
99
197
  session_start();
100
198
 
101
-
102
-
103
199
  $name = $_SESSION['name'];
104
200
 
105
201
  unset($_SESSION['name']);
106
202
 
107
-
108
-
109
203
  $email = $_SESSION['email'];
110
204
 
111
205
  unset($_SESSION['email']);
112
206
 
113
-
114
-
115
207
  $content = $_SESSION['content'];
116
208
 
117
209
  unset($_SESSION['content']);
@@ -128,8 +220,6 @@
128
220
 
129
221
  require '../PHPMailer/PHPMailerAutoload.php';
130
222
 
131
-
132
-
133
223
  $mail = new PHPMailer;
134
224
 
135
225
  $mail->isSMTP();
@@ -162,9 +252,7 @@
162
252
 
163
253
  ?>
164
254
 
165
-
255
+ ```
166
-
167
-
168
256
 
169
257
 
170
258
 
@@ -172,7 +260,7 @@
172
260
 
173
261
 
174
262
 
175
- confirm.phpにcomplete.phpの内容をコピペすると、xserverは問題なく入力した内容が届きました。
263
+ confirm.phpの後にcomplete.phpの内容をコピペすると、xserverは問題なく入力した内容が届きました。
176
264
 
177
265
  xSERVERのphp.iniの直接編集をこのように変えました。
178
266
 
@@ -186,10 +274,6 @@
186
274
 
187
275
 
188
276
 
189
- また、フォルダ直下にphp.iniを作成しました。
190
-
191
- session.save_path = /var/lib/php/session
192
-
193
277
 
194
278
 
195
279
  ### 補足情報(FW/ツールのバージョンなど)
@@ -201,3 +285,9 @@
201
285
  仮想環境(ドットインストール参照)
202
286
 
203
287
  Powershell→Vagrant→putty→Cyberduck
288
+
289
+
290
+
291
+ PHP
292
+
293
+ version 7.1.30