質問編集履歴

5

コードの修正

2018/10/17 08:08

投稿

Company_
Company_

スコア16

test CHANGED
File without changes
test CHANGED
@@ -186,22 +186,6 @@
186
186
 
187
187
 
188
188
 
189
- //ユーザ情報登録
190
-
191
- public function user_registaration($name, $pass)
192
-
193
- {
194
-
195
- $sql = "INSERT INTO ip_d_user_information(infouser_user_name, infouser_password) VALUES (?, ?)";
196
-
197
- $stmt = $this->link->prepare($sql);
198
-
199
- $stmt->execute(array($name, password_hash($pass, PASSWORD_DEFAULT)));
200
-
201
- }
202
-
203
-
204
-
205
189
  //名前重複チェック
206
190
 
207
191
  public function user_duplication($name)
@@ -240,10 +224,6 @@
240
224
 
241
225
  $username = $_POST["username"];
242
226
 
243
- $password = $_POST["password"];
244
-
245
- $password2 = $_POST["password2"];
246
-
247
227
 
248
228
 
249
229
  $user = new User_registaration;
@@ -254,8 +234,6 @@
254
234
 
255
235
 
256
236
 
257
- $user->user_registaration($username, $password);
258
-
259
237
  ```
260
238
 
261
239
  ```php

4

コードの修正

2018/10/17 08:08

投稿

Company_
Company_

スコア16

test CHANGED
File without changes
test CHANGED
@@ -161,3 +161,137 @@
161
161
  $smarty->display('signup.tpl');
162
162
 
163
163
  ```
164
+
165
+ ###修正後コード
166
+
167
+ ```php
168
+
169
+ <?php
170
+
171
+ require_once('db_connection.php');
172
+
173
+
174
+
175
+ class User_registaration extends Db_Connection
176
+
177
+ {
178
+
179
+ public function __construct()
180
+
181
+ {
182
+
183
+ parent::__construct();
184
+
185
+ }
186
+
187
+
188
+
189
+ //ユーザ情報登録
190
+
191
+ public function user_registaration($name, $pass)
192
+
193
+ {
194
+
195
+ $sql = "INSERT INTO ip_d_user_information(infouser_user_name, infouser_password) VALUES (?, ?)";
196
+
197
+ $stmt = $this->link->prepare($sql);
198
+
199
+ $stmt->execute(array($name, password_hash($pass, PASSWORD_DEFAULT)));
200
+
201
+ }
202
+
203
+
204
+
205
+ //名前重複チェック
206
+
207
+ public function user_duplication($name)
208
+
209
+ {
210
+
211
+ $sql = "SELECT * FROM ip_d_user_information";
212
+
213
+ //SQL文実行
214
+
215
+ $stmt = $this->link->query($sql);
216
+
217
+
218
+
219
+ while($item = $stmt->fetch())
220
+
221
+ {
222
+
223
+ if($name == $item['infouser_user_name'])
224
+
225
+ {
226
+
227
+ $error = "入力されたユーザ名は既に使われています";
228
+
229
+ return $error;
230
+
231
+ }
232
+
233
+ }
234
+
235
+ }
236
+
237
+ }
238
+
239
+
240
+
241
+ $username = $_POST["username"];
242
+
243
+ $password = $_POST["password"];
244
+
245
+ $password2 = $_POST["password2"];
246
+
247
+
248
+
249
+ $user = new User_registaration;
250
+
251
+
252
+
253
+ $er = $user->user_duplication($username);
254
+
255
+
256
+
257
+ $user->user_registaration($username, $password);
258
+
259
+ ```
260
+
261
+ ```php
262
+
263
+ <?php
264
+
265
+ require_once('Smarty.class.php');
266
+
267
+ require_once('../file_class/login_authentication.php');
268
+
269
+ require_once('../file_class/user_registration.php');
270
+
271
+
272
+
273
+ $smarty = new Smarty();
274
+
275
+
276
+
277
+ $smarty->template_dir = '../templates';
278
+
279
+ $smarty->compile_dir = '../templates_c';
280
+
281
+ $smarty->config_dir = '../configs/';
282
+
283
+ $smarty->cache_dir = '../cache/';
284
+
285
+
286
+
287
+ session_start();
288
+
289
+
290
+
291
+ $smarty->assign('signUpError', $er);
292
+
293
+
294
+
295
+ $smarty->display('signup.tpl');
296
+
297
+ ```

3

コードの修正

2018/10/17 07:57

投稿

Company_
Company_

スコア16

test CHANGED
File without changes
test CHANGED
@@ -31,16 +31,6 @@
31
31
  class User_registaration extends Db_Connection
32
32
 
33
33
  {
34
-
35
- public function __construct()
36
-
37
- {
38
-
39
- parent::__construct();
40
-
41
- }
42
-
43
-
44
34
 
45
35
  //ユーザ情報登録
46
36
 

2

修正

2018/10/17 03:14

投稿

Company_
Company_

スコア16

test CHANGED
File without changes
test CHANGED
@@ -3,6 +3,10 @@
3
3
  クラス内の名前重複チェックの"入力されたユーザ名は既に使われています"を
4
4
 
5
5
  smartyのテンプレートに受け渡したい
6
+
7
+ ###発生している問題
8
+
9
+ "入力されたユーザ名は既に使われています"が表示されない
6
10
 
7
11
  ###試したこと
8
12
 

1

誤字

2018/10/17 02:59

投稿

Company_
Company_

スコア16

test CHANGED
File without changes
test CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  クラス内の名前重複チェックの"入力されたユーザ名は既に使われています"を
4
4
 
5
- $smartyのテンプレートに受け渡したい
5
+ smartyのテンプレートに受け渡したい
6
6
 
7
7
  ###試したこと
8
8