質問編集履歴

1

すいません質問がわかりづらくて。エラーが発生しているphpのソースを貼りました。

2017/06/07 01:44

投稿

kacz-
kacz-

スコア16

test CHANGED
File without changes
test CHANGED
@@ -14,6 +14,70 @@
14
14
 
15
15
  各ページがmysqliでエラーを吐いております。
16
16
 
17
+
18
+
19
+ Notice: Undefined variable: link in /Applications/XAMPP/xamppfiles/htdocs/members/regist/user_regist.php on line 11
20
+
21
+
22
+
23
+ Notice: Undefined index: in /Applications/XAMPP/xamppfiles/htdocs/members/regist/user_regist.php on line 11
24
+
25
+
26
+
27
+ Notice: Undefined variable: link in /Applications/XAMPP/xamppfiles/htdocs/members/regist/user_regist.php on line 11
28
+
29
+
30
+
31
+ Notice: Undefined index: in /Applications/XAMPP/xamppfiles/htdocs/members/regist/user_regist.php on line 11
32
+
33
+
34
+
35
+ Notice: Undefined variable: link in /Applications/XAMPP/xamppfiles/htdocs/members/regist/user_regist.php on line 11
36
+
37
+
38
+
39
+ Notice: Undefined index: in /Applications/XAMPP/xamppfiles/htdocs/members/regist/user_regist.php on line 11
40
+
41
+
42
+
43
+ Notice: Undefined variable: link in /Applications/XAMPP/xamppfiles/htdocs/members/regist/user_regist.php on line 11
44
+
45
+
46
+
47
+ Notice: Undefined index: in /Applications/XAMPP/xamppfiles/htdocs/members/regist/user_regist.php on line 11
48
+
49
+
50
+
51
+ Warning: mysqli_query() expects at least 2 parameters, 1 given in /Applications/XAMPP/xamppfiles/htdocs/members/regist/user_regist.php on line 19
52
+
53
+
54
+
55
+ Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in /Applications/XAMPP/xamppfiles/htdocs/members/regist/user_regist.php on line 21
56
+
57
+
58
+
59
+ Warning: mysqli_query() expects at least 2 parameters, 1 given in /Applications/XAMPP/xamppfiles/htdocs/members/regist/user_regist.php on line 29
60
+
61
+
62
+
63
+ Warning: mysqli_query() expects at least 2 parameters, 1 given in /Applications/XAMPP/xamppfiles/htdocs/members/regist/user_regist.php on line 32
64
+
65
+
66
+
67
+ Warning: mysqli_query() expects at least 2 parameters, 1 given in /Applications/XAMPP/xamppfiles/htdocs/members/regist/user_regist.php on line 53
68
+
69
+ データベース登録エラー
70
+
71
+ Error: データベースに登録できませんでした。
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ このような感じたくさんエラーが発生しております。
80
+
17
81
  ```
18
82
 
19
83
 
@@ -32,6 +96,192 @@
32
96
 
33
97
  https://github.com/webcyou/sample/tree/master/php/members
34
98
 
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+ 下記が現在エラーを解消しようとしているphpです。
108
+
109
+
110
+
111
+ <?php
112
+
113
+ /* 入力フォームからパラメータを取得 */
114
+
115
+ /*******************************************************************************
116
+
117
+ *
118
+
119
+ * [user_regist.php] 会員登録と登録内容送信
120
+
121
+ *
122
+
123
+ ********************************************************************************/
124
+
125
+ $formList = array('mode', 'input_userid', 'input_password', 'input_name', 'input_email');
126
+
127
+ /* ポストデータを取得しパラメータと同名の変数に格納 */
128
+
129
+ foreach($formList as $value) {
130
+
131
+ $$value = $_POST[$value];
132
+
133
+ }
134
+
135
+ /* エラーメッセージの初期化 */
136
+
137
+ $error = array();
138
+
139
+ /* データベース接続設定 */
140
+
141
+ require_once('db.php');
142
+
143
+ /* ユーザーIDチェック */
144
+
145
+ $query = "select userid from members where userid = '$input_userid'";
146
+
147
+ $resultId = mysqli_query($query);
148
+
149
+
150
+
151
+ if(mysqli_num_rows($resultId) > 0 ) { //ユーザーIDが存在
152
+
153
+ array_push($error,"このユーザーIDはすでに登録されています。");
154
+
155
+ }
156
+
157
+
158
+
159
+ if(count($error) == 0) {
160
+
161
+
162
+
163
+ //登録するデーターにエラーがない場合、memberテーブルにデータを追加する。
164
+
165
+ //トランザクション開始
166
+
167
+ mysqli_query("begin");
168
+
169
+
170
+
171
+ $query = "insert into members(userid, password, name, email) values('$input_userid','$input_password','$input_name','$input_email')";
172
+
173
+ $result = mysqli_query($query);
174
+
175
+
176
+
177
+ if($result){ //登録完了
178
+
179
+
180
+
181
+ //トランザクション終わり
182
+
183
+ mysqli_query("commit");
184
+
185
+
186
+
187
+ /* 登録完了メールを送信 */
188
+
189
+ mb_language("japanese"); //言語の設定
190
+
191
+ mb_internal_encoding("utf-8");//内部エンコーディングの設定
192
+
193
+
194
+
195
+ $to = $input_email;
196
+
197
+ $subject = "会員登録URL送信メール";
198
+
199
+ $message = "会員登録ありがとうございました。\n"."登録いただいたユーザーIDは[$input_userid]です。";
200
+
201
+ $header = "From:test@test.com";
202
+
203
+
204
+
205
+ if(!mb_send_mail($to, $subject, $message, $header)) { //メール送信に失敗したら
206
+
207
+ array_push($error,"メールが送信できませんでした。<br>ただしデータベースへの登録は完了しています。");
208
+
209
+ }
210
+
211
+ } else { //データベースへの登録作業失敗
212
+
213
+ //ロールバック
214
+
215
+ mysqli_query("rollback");
216
+
217
+ array_push($error, "データベースに登録できませんでした。");
218
+
219
+ }
220
+
221
+ }
222
+
223
+
224
+
225
+ if(count($error) == 0) {
226
+
227
+ ?>
228
+
229
+ <table>
230
+
231
+ <caption>データベース登録完了</caption>
232
+
233
+ <tr>
234
+
235
+ <td class="item">Thanks:</td>
236
+
237
+ <td>登録ありがとうございます。<br>登録完了のお知らせをメールで送信しましたので、ご確認ください。</td>
238
+
239
+ </tr>
240
+
241
+ </table>
242
+
243
+
244
+
245
+ <?php
246
+
247
+ /* エラー内容表示 */
248
+
249
+ } else {
250
+
251
+ ?>
252
+
253
+ <table>
254
+
255
+ <caption>データベース登録エラー</caption>
256
+
257
+ <tr>
258
+
259
+ <td class="item">Error:</td>
260
+
261
+ <td>
262
+
263
+ <?php
264
+
265
+ foreach($error as $value) {
266
+
267
+ print $value;
268
+
269
+ ?>
270
+
271
+ </td>
272
+
273
+ </tr>
274
+
275
+ </table>
276
+
277
+ <?php
278
+
279
+ }
280
+
281
+ }
282
+
283
+ ?>
284
+
35
285
  ```
36
286
 
37
287