質問編集履歴

2

変更しました

2017/10/04 10:54

投稿

rura
rura

スコア70

test CHANGED
File without changes
test CHANGED
@@ -20,280 +20,278 @@
20
20
 
21
21
  ```
22
22
 
23
+ if (!empty($_POST["username"]) && !empty($_POST["email"]) &&!empty($_POST["password"]) &&
24
+
25
+ !empty($_POST["password2"]) && $_POST["password"] === $_POST["password2"] && !empty($_POST["EmployeeNum1"])&&!empty($_POST["Establishment"]) && !empty($_POST["Capitalstock"]) &&!empty($_POST["Capitalstock"]) && !empty($_POST["kabu"])&&
26
+
27
+ !empty($_POST["BusinessDomain"])) {
28
+
29
+ // 入力したユーザIDとパスワードを格納
30
+
31
+ $username = $_POST["username"];
32
+
33
+ $email = $_POST["email"];
34
+
35
+ $password = $_POST["password"];
36
+
37
+ $EmployeeNum1 = $_POST["EmployeeNum1"];
38
+
39
+ $Establishment = $_POST["Establishment"];
40
+
41
+ $Capitalstock = $_POST["Capitalstock"];
42
+
43
+ $kabu = $_POST["kabu"];
44
+
45
+ $BusinessDomain = $_POST["BusinessDomain"];
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+ // 2. ユーザIDとパスワードが入力されていたら認証する
54
+
55
+
56
+
57
+ $dsn = sprintf('mysql: host=%s; dbname=%s; charset=utf8', $db['host'], $db['dbname']);
58
+
59
+
60
+
61
+ // 3. エラー処理
62
+
63
+ try {
64
+
65
+ $pdo = new PDO($dsn, $db['user'], $db['pass'],array(PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION));
66
+
67
+ $sql="INSERT INTO userData(name,email,password,EmployeeNum1,Establishment,Capitalstock,kabu,BusinessDomain) VALUES (?, ?, ?, ?, ?,?, ?,?)";
68
+
69
+ $stmt = $pdo->prepare($sql);
70
+
71
+
72
+
73
+ // パスワードのハッシュ化を行う
74
+
75
+ //(今回は文字列のみなのでbindValue(変数内容が変化なし)を使用せず、直接excuteに渡しても問題ない) $stmt->execute(array($username,password_hash($password, PASSWORD_DEFAULT), $password,$EmployeeNum1,$Establishment,$Capitalstock,$kabu,$BusinessDomain));
76
+
77
+ // 登録した(DB側でauto_incrementした)IDを$useridに入れる
78
+
79
+ $userid = $pdo->lastinsertid();
80
+
81
+
82
+
83
+ echo "登録手続完了。あなたの情報は下記の通りとなりました。";
84
+
85
+ $signUpMessage = '登録IDは '. $userid. ' 。<br>パスワードは '. $password. ' 。メールアドレスは '. $email. ' 。'; // ログイン時に使用するIDとパスワード
86
+
87
+ } catch (PDOException $e) {
88
+
89
+ //$errorMessage = 'データベースエラー';
90
+
91
+ // $e->getMessage() //でエラー内容を参照可能(デバック時のみ表示)
92
+
93
+ echo $e->getMessage();
94
+
95
+ }
96
+
97
+ -省略-
98
+
99
+ <div class="form-group">
100
+
101
+ <label for="password" class="control-label">業務領域</label><br>
102
+
103
+ <input type="checkbox" name="BusinessDomain[]" value="財務、会計系" class="checkbox-inline"/>財務、会計系
104
+
105
+ <input type="checkbox" name="BusinessDomain[]" value="人事、給与、労務系" class="checkbox-inline"/>人事、給与、労務系
106
+
107
+ <input type="checkbox" name="BusinessDomain[]" value="営業、販売系 " class="checkbox-inline"/>営業、販売系
108
+
109
+ <input type="checkbox" name="BusinessDomain[]" value="生産管理系 " class="checkbox-inline"/>生産管理系
110
+
111
+ <input type="checkbox" name="BusinessDomain[]" value="物流系" class="checkbox-inline"/>物流系
112
+
113
+ <input type="checkbox" name="BusinessDomain[]" value="ゲーム" class="checkbox-inline"/>ゲーム
114
+
115
+ </div>
116
+
117
+ <label for="password" class="control-label">勤務地</label><br>
118
+
119
+ <table class="table table-hover">
120
+
121
+ <tbody>
122
+
123
+ <tr>
124
+
125
+ <td class="active">北海道 / 東北</td>
126
+
127
+ <td>
128
+
129
+ <input type="checkbox" name="prefectures" value="県" />北海道
130
+
131
+ <input type="checkbox" name="prefectures" value="県" />青森県
132
+
133
+ <input type="checkbox" name="prefectures" value="県" />岩手県
134
+
135
+ <input type="checkbox" name="prefectures" value="県" />宮城県
136
+
137
+ <input type="checkbox" name="prefectures" value="県" />秋田県
138
+
139
+ <input type="checkbox" name="prefectures" value="県" />山形県
140
+
141
+ <input type="checkbox" name="prefectures" value="県" />福島県
142
+
143
+ </td>
144
+
145
+ </tr>
146
+
147
+ <tr>
148
+
149
+ <td class="active">関東</td>
150
+
151
+ <td>
152
+
153
+ <input type="checkbox" name="prefectures" value="県" />茨城県
154
+
155
+ <input type="checkbox" name="prefectures" value="県" />栃木県
156
+
157
+ <input type="checkbox" name="prefectures" value="県" />群馬県
158
+
159
+ <input type="checkbox" name="prefectures" value="県" />埼玉県
160
+
161
+ <input type="checkbox" name="prefectures" value="県" />千葉県
162
+
163
+ <input type="checkbox" name="prefectures" value="県" />東京都
164
+
165
+ <input type="checkbox" name="prefectures" value="県" />神奈川県
166
+
167
+ </td>
168
+
169
+ </tr>
170
+
171
+ <tr>
172
+
173
+ <td class="active">中部</td>
174
+
175
+ <td>
176
+
177
+ <input type="checkbox" name="prefectures" value="県" />新潟県
178
+
179
+ <input type="checkbox" name="prefectures" value="県" />富山県
180
+
181
+ <input type="checkbox" name="prefectures" value="県" />石川県
182
+
183
+ <input type="checkbox" name="prefectures" value="県" />福井県
184
+
185
+ <input type="checkbox" name="prefectures" value="県" />山梨県
186
+
187
+ <input type="checkbox" name="prefectures" value="県" />長野県
188
+
189
+ <input type="checkbox" name="prefectures" value="県" />岐阜県
190
+
191
+ <input type="checkbox" name="prefectures" value="県" />静岡県
192
+
193
+ <input type="checkbox" name="prefectures" value="県" />愛知県
194
+
195
+ </td>
196
+
197
+ </tr>
198
+
199
+ <tr>
200
+
201
+ <td class="active">近畿</td>
202
+
203
+ <td>
204
+
205
+ <input type="checkbox" name="prefectures" value="県" />三重県
206
+
207
+ <input type="checkbox" name="prefectures" value="県" />滋賀県
208
+
209
+ <input type="checkbox" name="prefectures" value="県" />京都府
210
+
211
+ <input type="checkbox" name="prefectures" value="県" />大阪府
212
+
213
+ <input type="checkbox" name="prefectures" value="県" />兵庫県
214
+
215
+ <input type="checkbox" name="prefectures" value="県" />奈良県
216
+
217
+ <input type="checkbox" name="prefectures" value="県" />和歌山県
218
+
219
+ </td>
220
+
221
+ </tr>
222
+
223
+ <tr>
224
+
225
+ <td class="active">中国</td>
226
+
227
+ <td>
228
+
229
+ <input type="checkbox" name="prefectures" value="県" />鳥取県
230
+
231
+ <input type="checkbox" name="prefectures" value="県" />島根県
232
+
233
+ <input type="checkbox" name="prefectures" value="県" />岡山県
234
+
235
+ <input type="checkbox" name="prefectures" value="県" />広島県
236
+
237
+ <input type="checkbox" name="prefectures" value="県" />山口県
238
+
239
+ </td>
240
+
241
+ </tr>
242
+
243
+ <tr>
244
+
245
+ <td class="active">四国</td>
246
+
247
+ <td>
248
+
249
+ <input type="checkbox" name="prefectures" value="県" />徳島県
250
+
251
+ <input type="checkbox" name="prefectures" value="県" />香川県
252
+
253
+ <input type="checkbox" name="prefectures" value="県" />愛媛県
254
+
255
+ <input type="checkbox" name="prefectures" value="県" />高知県
256
+
257
+ </td>
258
+
259
+ </tr>
260
+
261
+ <tr>
262
+
263
+ <td class="active">九州 / 沖縄</td>
264
+
265
+ <td>
266
+
267
+ <input type="checkbox" name="prefectures" value="県" />福岡県
268
+
269
+ <input type="checkbox" name="prefectures" value="県" />佐賀県
270
+
271
+ <input type="checkbox" name="prefectures" value="県" />長崎県
272
+
273
+ <input type="checkbox" name="prefectures" value="県" />熊本県
274
+
275
+ <input type="checkbox" name="prefectures" value="県" />大分県
276
+
277
+ <input type="checkbox" name="prefectures" value="県" />宮崎県
278
+
279
+ <input type="checkbox" name="prefectures" value="県" />鹿児島県
280
+
281
+ <input type="checkbox" name="prefectures" value="県" />沖縄県
282
+
283
+ </td>
284
+
285
+ <tr>
286
+
287
+ </tbody>
288
+
289
+   </table>
290
+
23
291
 
24
292
 
25
293
  ```ここに言語を入力
26
294
 
27
- if (!empty($_POST["username"]) && !empty($_POST["email"]) &&!empty($_POST["password"]) &&
28
-
29
- !empty($_POST["password2"]) && $_POST["password"] === $_POST["password2"] && !empty($_POST["EmployeeNum1"])&&
30
-
31
- !empty($_POST["Establishment"]) && !empty($_POST["Capitalstock"]) &&!empty($_POST["Capitalstock"]) && !empty($_POST["kabu"])&&
32
-
33
- !empty($_POST["BusinessDomain"])) {
34
-
35
- // 入力したユーザIDとパスワードを格納
36
-
37
- $username = $_POST["username"];
38
-
39
- $email = $_POST["email"];
40
-
41
- $password = $_POST["password"];
42
-
43
- $EmployeeNum1 = $_POST["EmployeeNum1"];
44
-
45
- $Establishment = $_POST["Establishment"];
46
-
47
- $Capitalstock = $_POST["Capitalstock"];
48
-
49
- $kabu = $_POST["kabu"];
50
-
51
- $BusinessDomain = $_POST["BusinessDomain"];
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
- // 2. ユーザIDとパスワードが入力されていたら認証する
60
-
61
-
62
-
63
- $dsn = sprintf('mysql: host=%s; dbname=%s; charset=utf8', $db['host'], $db['dbname']);
64
-
65
-
66
-
67
- // 3. エラー処理
68
-
69
- try {
70
-
71
- $pdo = new PDO($dsn, $db['user'], $db['pass'],array(PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION));
72
-
73
- $sql="INSERT INTO userData(name,email,password,EmployeeNum1,Establishment,Capitalstock,kabu,BusinessDomain) VALUES (?, ?, ?, ?, ?,?, ?,?)";
74
-
75
- $stmt = $pdo->prepare($sql);
76
-
77
-
78
-
79
- // パスワードのハッシュ化を行う
80
-
81
- //(今回は文字列のみなのでbindValue(変数内容が変化なし)を使用せず、直接excuteに渡しても問題ない) $stmt->execute(array($username,password_hash($password, PASSWORD_DEFAULT), $password,$EmployeeNum1,$Establishment,$Capitalstock,$kabu,$BusinessDomain));
82
-
83
- // 登録した(DB側でauto_incrementした)IDを$useridに入れる
84
-
85
- $userid = $pdo->lastinsertid();
86
-
87
-
88
-
89
- echo "登録手続完了。あなたの情報は下記の通りとなりました。";
90
-
91
- $signUpMessage = '登録IDは '. $userid. ' 。<br>パスワードは '. $password. ' 。メールアドレスは '. $email. ' 。'; // ログイン時に使用するIDとパスワード
92
-
93
- } catch (PDOException $e) {
94
-
95
- //$errorMessage = 'データベースエラー';
96
-
97
- // $e->getMessage() //でエラー内容を参照可能(デバック時のみ表示)
98
-
99
- echo $e->getMessage();
100
-
101
- }
102
-
103
- -省略-
104
-
105
- <div class="form-group">
106
-
107
- <label for="password" class="control-label">業務領域</label><br>
108
-
109
- <input type="checkbox" name="BusinessDomain[]" value="財務、会計系" class="checkbox-inline"/>財務、会計系
110
-
111
- <input type="checkbox" name="BusinessDomain[]" value="人事、給与、労務系" class="checkbox-inline"/>人事、給与、労務系
112
-
113
- <input type="checkbox" name="BusinessDomain[]" value="営業、販売系 " class="checkbox-inline"/>営業、販売系
114
-
115
- <input type="checkbox" name="BusinessDomain[]" value="生産管理系 " class="checkbox-inline"/>生産管理系
116
-
117
- <input type="checkbox" name="BusinessDomain[]" value="物流系" class="checkbox-inline"/>物流系
118
-
119
- <input type="checkbox" name="BusinessDomain[]" value="ゲーム" class="checkbox-inline"/>ゲーム
120
-
121
- </div>
122
-
123
- <label for="password" class="control-label">勤務地</label><br>
124
-
125
- <table class="table table-hover">
126
-
127
- <tbody>
128
-
129
- <tr>
130
-
131
- <td class="active">北海道 / 東北</td>
132
-
133
- <td>
134
-
135
- <input type="checkbox" name="prefectures" value="県" />北海道
136
-
137
- <input type="checkbox" name="prefectures" value="県" />青森県
138
-
139
- <input type="checkbox" name="prefectures" value="県" />岩手県
140
-
141
- <input type="checkbox" name="prefectures" value="県" />宮城県
142
-
143
- <input type="checkbox" name="prefectures" value="県" />秋田県
144
-
145
- <input type="checkbox" name="prefectures" value="県" />山形県
146
-
147
- <input type="checkbox" name="prefectures" value="県" />福島県
148
-
149
- </td>
150
-
151
- </tr>
152
-
153
- <tr>
154
-
155
- <td class="active">関東</td>
156
-
157
- <td>
158
-
159
- <input type="checkbox" name="prefectures" value="県" />茨城県
160
-
161
- <input type="checkbox" name="prefectures" value="県" />栃木県
162
-
163
- <input type="checkbox" name="prefectures" value="県" />群馬県
164
-
165
- <input type="checkbox" name="prefectures" value="県" />埼玉県
166
-
167
- <input type="checkbox" name="prefectures" value="県" />千葉県
168
-
169
- <input type="checkbox" name="prefectures" value="県" />東京都
170
-
171
- <input type="checkbox" name="prefectures" value="県" />神奈川県
172
-
173
- </td>
174
-
175
- </tr>
176
-
177
- <tr>
178
-
179
- <td class="active">中部</td>
180
-
181
- <td>
182
-
183
- <input type="checkbox" name="prefectures" value="県" />新潟県
184
-
185
- <input type="checkbox" name="prefectures" value="県" />富山県
186
-
187
- <input type="checkbox" name="prefectures" value="県" />石川県
188
-
189
- <input type="checkbox" name="prefectures" value="県" />福井県
190
-
191
- <input type="checkbox" name="prefectures" value="県" />山梨県
192
-
193
- <input type="checkbox" name="prefectures" value="県" />長野県
194
-
195
- <input type="checkbox" name="prefectures" value="県" />岐阜県
196
-
197
- <input type="checkbox" name="prefectures" value="県" />静岡県
198
-
199
- <input type="checkbox" name="prefectures" value="県" />愛知県
200
-
201
- </td>
202
-
203
- </tr>
204
-
205
- <tr>
206
-
207
- <td class="active">近畿</td>
208
-
209
- <td>
210
-
211
- <input type="checkbox" name="prefectures" value="県" />三重県
212
-
213
- <input type="checkbox" name="prefectures" value="県" />滋賀県
214
-
215
- <input type="checkbox" name="prefectures" value="県" />京都府
216
-
217
- <input type="checkbox" name="prefectures" value="県" />大阪府
218
-
219
- <input type="checkbox" name="prefectures" value="県" />兵庫県
220
-
221
- <input type="checkbox" name="prefectures" value="県" />奈良県
222
-
223
- <input type="checkbox" name="prefectures" value="県" />和歌山県
224
-
225
- </td>
226
-
227
- </tr>
228
-
229
- <tr>
230
-
231
- <td class="active">中国</td>
232
-
233
- <td>
234
-
235
- <input type="checkbox" name="prefectures" value="県" />鳥取県
236
-
237
- <input type="checkbox" name="prefectures" value="県" />島根県
238
-
239
- <input type="checkbox" name="prefectures" value="県" />岡山県
240
-
241
- <input type="checkbox" name="prefectures" value="県" />広島県
242
-
243
- <input type="checkbox" name="prefectures" value="県" />山口県
244
-
245
- </td>
246
-
247
- </tr>
248
-
249
- <tr>
250
-
251
- <td class="active">四国</td>
252
-
253
- <td>
254
-
255
- <input type="checkbox" name="prefectures" value="県" />徳島県
256
-
257
- <input type="checkbox" name="prefectures" value="県" />香川県
258
-
259
- <input type="checkbox" name="prefectures" value="県" />愛媛県
260
-
261
- <input type="checkbox" name="prefectures" value="県" />高知県
262
-
263
- </td>
264
-
265
- </tr>
266
-
267
- <tr>
268
-
269
- <td class="active">九州 / 沖縄</td>
270
-
271
- <td>
272
-
273
- <input type="checkbox" name="prefectures" value="県" />福岡県
274
-
275
- <input type="checkbox" name="prefectures" value="県" />佐賀県
276
-
277
- <input type="checkbox" name="prefectures" value="県" />長崎県
278
-
279
- <input type="checkbox" name="prefectures" value="県" />熊本県
280
-
281
- <input type="checkbox" name="prefectures" value="県" />大分県
282
-
283
- <input type="checkbox" name="prefectures" value="県" />宮崎県
284
-
285
- <input type="checkbox" name="prefectures" value="県" />鹿児島県
286
-
287
- <input type="checkbox" name="prefectures" value="県" />沖縄県
288
-
289
- </td>
290
-
291
- <tr>
292
-
293
- </tbody>
294
-
295
-   </table>
296
-
297
295
 
298
296
 
299
297
 

1

ちょっと改行しました。

2017/10/04 10:54

投稿

rura
rura

スコア70

test CHANGED
File without changes
test CHANGED
@@ -22,6 +22,8 @@
22
22
 
23
23
 
24
24
 
25
+ ```ここに言語を入力
26
+
25
27
  if (!empty($_POST["username"]) && !empty($_POST["email"]) &&!empty($_POST["password"]) &&
26
28
 
27
29
  !empty($_POST["password2"]) && $_POST["password"] === $_POST["password2"] && !empty($_POST["EmployeeNum1"])&&
@@ -52,9 +54,13 @@
52
54
 
53
55
 
54
56
 
57
+
58
+
55
59
  // 2. ユーザIDとパスワードが入力されていたら認証する
56
60
 
61
+
62
+
57
- $dsn = sprintf('mysql: host=%s; dbname=%s; charset=utf8', $db['host'], $db['dbname']);
63
+ $dsn = sprintf('mysql: host=%s; dbname=%s; charset=utf8', $db['host'], $db['dbname']);
58
64
 
59
65
 
60
66
 
@@ -62,27 +68,27 @@
62
68
 
63
69
  try {
64
70
 
65
- $pdo = new PDO($dsn, $db['user'], $db['pass'], array(PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION));
71
+ $pdo = new PDO($dsn, $db['user'], $db['pass'],array(PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION));
66
-
72
+
67
- $sql="INSERT INTO userData(name, email,password,EmployeeNum1,Establishment,Capitalstock,kabu,BusinessDomain) VALUES (?, ?, ?, ?, ?,?, ?,?)";
73
+ $sql="INSERT INTO userData(name,email,password,EmployeeNum1,Establishment,Capitalstock,kabu,BusinessDomain) VALUES (?, ?, ?, ?, ?,?, ?,?)";
68
-
74
+
69
- $stmt = $pdo->prepare($sql);
75
+ $stmt = $pdo->prepare($sql);
70
76
 
71
77
 
72
78
 
73
-
74
-
75
- // パスワードのハッシュ化を行う(今回は文字列のみなのでbindValue(変数内容が変わら)を使用せず、直接excuteに渡しても問題ない)
76
-
77
- $stmt->execute(array($username,password_hash($password, PASSWORD_DEFAULT), $password,$EmployeeNum1,$Establishment,$Capitalstock,$kabu,$BusinessDomain));
78
-
79
- $userid = $pdo->lastinsertid(); // 登録した(DB側でauto_incrementした)IDを$useridに入れる
80
-
81
-
82
-
83
- echo "登録手続完了。あなたの情報は下記の通りとなりました。";
84
-
85
- $signUpMessage = '登録IDは '. $userid. ' 。<br>パスワードは '. $password. ' 。メールアドレスは '. $email. ' 。'; // ログイン時に使用するIDとパスワード
79
+ // パスワードのハッシュ化を行う
80
+
81
+ //(今回は文字列のみなのでbindValue(変数内容が変)を使用せず、直接excuteに渡しても問題ない) $stmt->execute(array($username,password_hash($password, PASSWORD_DEFAULT), $password,$EmployeeNum1,$Establishment,$Capitalstock,$kabu,$BusinessDomain));
82
+
83
+ // 登録した(DB側でauto_incrementした)IDを$useridに入れる
84
+
85
+ $userid = $pdo->lastinsertid();
86
+
87
+
88
+
89
+ echo "登録手続完了。あなたの情報は下記の通りとなりました。";
90
+
91
+ $signUpMessage = '登録IDは '. $userid. ' 。<br>パスワードは '. $password. ' 。メールアドレスは '. $email. ' 。'; // ログイン時に使用するIDとパスワード
86
92
 
87
93
  } catch (PDOException $e) {
88
94