teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

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

2017/06/07 01:44

投稿

kacz-
kacz-

スコア16

title CHANGED
File without changes
body CHANGED
@@ -6,6 +6,38 @@
6
6
 
7
7
  ```
8
8
  各ページがmysqliでエラーを吐いております。
9
+
10
+ Notice: Undefined variable: link in /Applications/XAMPP/xamppfiles/htdocs/members/regist/user_regist.php on line 11
11
+
12
+ Notice: Undefined index: in /Applications/XAMPP/xamppfiles/htdocs/members/regist/user_regist.php on line 11
13
+
14
+ Notice: Undefined variable: link in /Applications/XAMPP/xamppfiles/htdocs/members/regist/user_regist.php on line 11
15
+
16
+ Notice: Undefined index: in /Applications/XAMPP/xamppfiles/htdocs/members/regist/user_regist.php on line 11
17
+
18
+ Notice: Undefined variable: link in /Applications/XAMPP/xamppfiles/htdocs/members/regist/user_regist.php on line 11
19
+
20
+ Notice: Undefined index: in /Applications/XAMPP/xamppfiles/htdocs/members/regist/user_regist.php on line 11
21
+
22
+ Notice: Undefined variable: link in /Applications/XAMPP/xamppfiles/htdocs/members/regist/user_regist.php on line 11
23
+
24
+ Notice: Undefined index: in /Applications/XAMPP/xamppfiles/htdocs/members/regist/user_regist.php on line 11
25
+
26
+ Warning: mysqli_query() expects at least 2 parameters, 1 given in /Applications/XAMPP/xamppfiles/htdocs/members/regist/user_regist.php on line 19
27
+
28
+ 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
29
+
30
+ Warning: mysqli_query() expects at least 2 parameters, 1 given in /Applications/XAMPP/xamppfiles/htdocs/members/regist/user_regist.php on line 29
31
+
32
+ Warning: mysqli_query() expects at least 2 parameters, 1 given in /Applications/XAMPP/xamppfiles/htdocs/members/regist/user_regist.php on line 32
33
+
34
+ Warning: mysqli_query() expects at least 2 parameters, 1 given in /Applications/XAMPP/xamppfiles/htdocs/members/regist/user_regist.php on line 53
35
+ データベース登録エラー
36
+ Error: データベースに登録できませんでした。
37
+
38
+
39
+
40
+ このような感じたくさんエラーが発生しております。
9
41
  ```
10
42
 
11
43
  ###該当のソースコード
@@ -15,6 +47,99 @@
15
47
 
16
48
  Githubで公開されている参考ページのデータ
17
49
  https://github.com/webcyou/sample/tree/master/php/members
50
+
51
+
52
+
53
+
54
+ 下記が現在エラーを解消しようとしているphpです。
55
+
56
+ <?php
57
+ /* 入力フォームからパラメータを取得 */
58
+ /*******************************************************************************
59
+ *
60
+ * [user_regist.php] 会員登録と登録内容送信
61
+ *
62
+ ********************************************************************************/
63
+ $formList = array('mode', 'input_userid', 'input_password', 'input_name', 'input_email');
64
+ /* ポストデータを取得しパラメータと同名の変数に格納 */
65
+ foreach($formList as $value) {
66
+ $$value = $_POST[$value];
67
+ }
68
+ /* エラーメッセージの初期化 */
69
+ $error = array();
70
+ /* データベース接続設定 */
71
+ require_once('db.php');
72
+ /* ユーザーIDチェック */
73
+ $query = "select userid from members where userid = '$input_userid'";
74
+ $resultId = mysqli_query($query);
75
+
76
+ if(mysqli_num_rows($resultId) > 0 ) { //ユーザーIDが存在
77
+ array_push($error,"このユーザーIDはすでに登録されています。");
78
+ }
79
+
80
+ if(count($error) == 0) {
81
+
82
+ //登録するデーターにエラーがない場合、memberテーブルにデータを追加する。
83
+ //トランザクション開始
84
+ mysqli_query("begin");
85
+
86
+ $query = "insert into members(userid, password, name, email) values('$input_userid','$input_password','$input_name','$input_email')";
87
+ $result = mysqli_query($query);
88
+
89
+ if($result){ //登録完了
90
+
91
+ //トランザクション終わり
92
+ mysqli_query("commit");
93
+
94
+ /* 登録完了メールを送信 */
95
+ mb_language("japanese"); //言語の設定
96
+ mb_internal_encoding("utf-8");//内部エンコーディングの設定
97
+
98
+ $to = $input_email;
99
+ $subject = "会員登録URL送信メール";
100
+ $message = "会員登録ありがとうございました。\n"."登録いただいたユーザーIDは[$input_userid]です。";
101
+ $header = "From:test@test.com";
102
+
103
+ if(!mb_send_mail($to, $subject, $message, $header)) { //メール送信に失敗したら
104
+ array_push($error,"メールが送信できませんでした。<br>ただしデータベースへの登録は完了しています。");
105
+ }
106
+ } else { //データベースへの登録作業失敗
107
+ //ロールバック
108
+ mysqli_query("rollback");
109
+ array_push($error, "データベースに登録できませんでした。");
110
+ }
111
+ }
112
+
113
+ if(count($error) == 0) {
114
+ ?>
115
+ <table>
116
+ <caption>データベース登録完了</caption>
117
+ <tr>
118
+ <td class="item">Thanks:</td>
119
+ <td>登録ありがとうございます。<br>登録完了のお知らせをメールで送信しましたので、ご確認ください。</td>
120
+ </tr>
121
+ </table>
122
+
123
+ <?php
124
+ /* エラー内容表示 */
125
+ } else {
126
+ ?>
127
+ <table>
128
+ <caption>データベース登録エラー</caption>
129
+ <tr>
130
+ <td class="item">Error:</td>
131
+ <td>
132
+ <?php
133
+ foreach($error as $value) {
134
+ print $value;
135
+ ?>
136
+ </td>
137
+ </tr>
138
+ </table>
139
+ <?php
140
+ }
141
+ }
142
+ ?>
18
143
  ```
19
144
 
20
145
  ###試したこと