質問編集履歴
7
コードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,57 +32,57 @@
|
|
32
32
|
|
33
33
|
|
34
34
|
|
35
|
+
//ユーザ情報登録
|
36
|
+
|
35
|
-
public function user_registaration($
|
37
|
+
public function user_registaration($name, $pass)
|
36
38
|
|
37
39
|
{
|
38
40
|
|
41
|
+
$sql = "INSERT INTO ip_d_user_information(infouser_user_name, infouser_password) VALUES (?, ?)";
|
42
|
+
|
43
|
+
$stmt = $this->link->prepare($sql);
|
44
|
+
|
45
|
+
$stmt->execute(array($name, password_hash($pass, PASSWORD_DEFAULT)));
|
46
|
+
|
47
|
+
}
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
//名前重複チェック
|
52
|
+
|
53
|
+
public function user_duplication($name)
|
54
|
+
|
55
|
+
{
|
56
|
+
|
57
|
+
$sql = "SELECT * FROM ip_d_user_information";
|
58
|
+
|
39
|
-
|
59
|
+
//SQL文実行
|
60
|
+
|
61
|
+
$stmt = $this->link->query($sql);
|
62
|
+
|
63
|
+
try
|
40
64
|
|
41
65
|
{
|
42
66
|
|
43
|
-
|
67
|
+
while($item = $stmt->fetch())
|
68
|
+
|
44
|
-
|
69
|
+
{
|
70
|
+
|
45
|
-
if
|
71
|
+
if($name == $item['infouser_user_name'])
|
72
|
+
|
73
|
+
{
|
74
|
+
|
75
|
+
throw new Exception('入力されたユーザ名は既に使われています');
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
}catch(Exception $e)
|
46
82
|
|
47
83
|
{
|
48
84
|
|
49
|
-
|
50
|
-
|
51
|
-
try
|
52
|
-
|
53
|
-
{
|
54
|
-
|
55
|
-
$sql = "INSERT INTO ip_d_user_information(infouser_user_name, infouser_password) VALUES (?, ?)";
|
56
|
-
|
57
|
-
$stmt = $this->link->prepare($sql);
|
58
|
-
|
59
|
-
$stmt->execute(array($name, password_hash($pass, PASSWORD_DEFAULT)));
|
60
|
-
|
61
|
-
}catch(PDOException $e)
|
62
|
-
|
63
|
-
{
|
64
|
-
|
65
|
-
|
85
|
+
$_SESSION["error"] = $e->getMessage();
|
66
|
-
|
67
|
-
}
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
}else if (empty($name) && empty($pass) && empty($pass2))
|
72
|
-
|
73
|
-
{
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
}else
|
78
|
-
|
79
|
-
{
|
80
|
-
|
81
|
-
$errorMessage = '正しく入力されていません';
|
82
|
-
|
83
|
-
$smarty->assign('signUpError', $errorMessage);
|
84
|
-
|
85
|
-
}
|
86
86
|
|
87
87
|
}
|
88
88
|
|
@@ -92,8 +92,6 @@
|
|
92
92
|
|
93
93
|
|
94
94
|
|
95
|
-
$signupbtn = $_POST["signUp"];
|
96
|
-
|
97
95
|
$username = $_POST["username"];
|
98
96
|
|
99
97
|
$password = $_POST["password"];
|
@@ -106,7 +104,11 @@
|
|
106
104
|
|
107
105
|
|
108
106
|
|
107
|
+
$user->user_duplication($username);
|
108
|
+
|
109
|
+
|
110
|
+
|
109
|
-
$user->user_registaration($
|
111
|
+
$user->user_registaration($username, $password);
|
110
112
|
|
111
113
|
```
|
112
114
|
|
@@ -150,6 +152,10 @@
|
|
150
152
|
|
151
153
|
|
152
154
|
|
155
|
+
$smarty->assign(signUpError, $_SESSION["error"]);
|
156
|
+
|
157
|
+
|
158
|
+
|
153
159
|
$smarty->display('signup.tpl');
|
154
160
|
|
155
161
|
```
|
6
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -154,6 +154,94 @@
|
|
154
154
|
|
155
155
|
```
|
156
156
|
|
157
|
+
```tpl
|
158
|
+
|
159
|
+
{config_load file="layout.conf"}
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
{$smarty.config.head} {* ヘッドの呼出 *}
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
<script type="text/javascript" src="js/signup.js" charset="UTF-8">
|
168
|
+
|
169
|
+
</script>
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
<body>
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
<div id="contents">
|
178
|
+
|
179
|
+
<h1>新規ユーザ登録</h1>
|
180
|
+
|
181
|
+
<form id="loginForm" name="loginForm" action="signup.php" method="POST">
|
182
|
+
|
183
|
+
<table>
|
184
|
+
|
185
|
+
<tr>
|
186
|
+
|
187
|
+
<div class="error">{$signUpError}{$dbError}</div>
|
188
|
+
|
189
|
+
<div class="input success">{$signUpMessage}</div>
|
190
|
+
|
191
|
+
<td><label for="username">ユーザ名</label></td>
|
192
|
+
|
193
|
+
<td><input type="text" id="signusername" name="username">
|
194
|
+
|
195
|
+
<p class="f-xs mt5">ユーザ名は5~20文字の範囲で入力してください</p></td>
|
196
|
+
|
197
|
+
</tr>
|
198
|
+
|
199
|
+
<br>
|
200
|
+
|
201
|
+
<tr>
|
202
|
+
|
203
|
+
<td><label for="password">パスワード</label></td>
|
204
|
+
|
205
|
+
<td><input type="password" id="signpassword" name="password" value="">
|
206
|
+
|
207
|
+
<p class="f-xs mt5">パスワードは8~16文字の範囲で入力してください</p></td>
|
208
|
+
|
209
|
+
</tr>
|
210
|
+
|
211
|
+
<br>
|
212
|
+
|
213
|
+
<tr>
|
214
|
+
|
215
|
+
<td><label for="password2">パスワード(確認用)</label></td>
|
216
|
+
|
217
|
+
<td><input type="password" id="signpassword2" name="password2" value="">
|
218
|
+
|
219
|
+
<p class="f-xs mt5">パスワードは8~16文字の範囲で入力してください</p></td>
|
220
|
+
|
221
|
+
</tr>
|
222
|
+
|
223
|
+
</table>
|
224
|
+
|
225
|
+
<br>
|
226
|
+
|
227
|
+
<button class="signup_btn" type="submit" id="confirm" name="confirm">入力内容確認</button>
|
228
|
+
|
229
|
+
<button class="signup_btn" type="submit" id="signUp" name="signUp">登録</button>
|
230
|
+
|
231
|
+
</form>
|
232
|
+
|
233
|
+
</div>
|
234
|
+
|
235
|
+
</body>
|
236
|
+
|
237
|
+
</html>
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
```
|
244
|
+
|
157
245
|
|
158
246
|
|
159
247
|
そもそもクラス内で$smarty->assign('signUpError', $errorMessage);を記述しても意味がないのでしょうか
|
5
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -66,7 +66,7 @@
|
|
66
66
|
|
67
67
|
}
|
68
68
|
|
69
|
-
|
69
|
+
|
70
70
|
|
71
71
|
}else if (empty($name) && empty($pass) && empty($pass2))
|
72
72
|
|
@@ -82,13 +82,15 @@
|
|
82
82
|
|
83
83
|
$smarty->assign('signUpError', $errorMessage);
|
84
84
|
|
85
|
-
|
85
|
+
}
|
86
86
|
|
87
87
|
}
|
88
88
|
|
89
89
|
}
|
90
90
|
|
91
91
|
}
|
92
|
+
|
93
|
+
|
92
94
|
|
93
95
|
$signupbtn = $_POST["signUp"];
|
94
96
|
|
4
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -66,7 +66,7 @@
|
|
66
66
|
|
67
67
|
}
|
68
68
|
|
69
|
-
|
69
|
+
}
|
70
70
|
|
71
71
|
}else if (empty($name) && empty($pass) && empty($pass2))
|
72
72
|
|
@@ -82,7 +82,7 @@
|
|
82
82
|
|
83
83
|
$smarty->assign('signUpError', $errorMessage);
|
84
84
|
|
85
|
-
|
85
|
+
|
86
86
|
|
87
87
|
}
|
88
88
|
|
3
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -66,8 +66,6 @@
|
|
66
66
|
|
67
67
|
}
|
68
68
|
|
69
|
-
}
|
70
|
-
|
71
69
|
|
72
70
|
|
73
71
|
}else if (empty($name) && empty($pass) && empty($pass2))
|
@@ -88,9 +86,9 @@
|
|
88
86
|
|
89
87
|
}
|
90
88
|
|
89
|
+
}
|
90
|
+
|
91
91
|
}
|
92
|
-
|
93
|
-
|
94
92
|
|
95
93
|
$signupbtn = $_POST["signUp"];
|
96
94
|
|
2
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -58,13 +58,17 @@
|
|
58
58
|
|
59
59
|
$stmt->execute(array($name, password_hash($pass, PASSWORD_DEFAULT)));
|
60
60
|
|
61
|
-
}catch(PDOException $e)
|
61
|
+
}catch(PDOException $e)
|
62
|
+
|
63
|
+
{
|
62
64
|
|
63
65
|
die($e->getMessage());
|
64
66
|
|
67
|
+
}
|
68
|
+
|
65
69
|
}
|
66
70
|
|
67
|
-
|
71
|
+
|
68
72
|
|
69
73
|
}else if (empty($name) && empty($pass) && empty($pass2))
|
70
74
|
|
@@ -82,7 +86,7 @@
|
|
82
86
|
|
83
87
|
}
|
84
88
|
|
85
|
-
}
|
89
|
+
}
|
86
90
|
|
87
91
|
}
|
88
92
|
|
1
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -57,10 +57,6 @@
|
|
57
57
|
$stmt = $this->link->prepare($sql);
|
58
58
|
|
59
59
|
$stmt->execute(array($name, password_hash($pass, PASSWORD_DEFAULT)));
|
60
|
-
|
61
|
-
$rows = $stmt->fetch(PDO::FETCH_ASSOC);
|
62
|
-
|
63
|
-
var_dump($rows);
|
64
60
|
|
65
61
|
}catch(PDOException $e){
|
66
62
|
|