質問編集履歴
7
補足
test
CHANGED
File without changes
|
test
CHANGED
@@ -236,6 +236,12 @@
|
|
236
236
|
|
237
237
|
|
238
238
|
|
239
|
+
オプションで全文チェックした結果
|
240
|
+
|
241
|
+
![イメージ説明](aa0b2b4cdb50a18f2cfd1dc64d07f677.png)
|
242
|
+
|
243
|
+
|
244
|
+
|
239
245
|
似たような質問もあったので参考にはしたんですが、それでも解決まで至れなかったのでアドバイスなどいただけると助かります!
|
240
246
|
|
241
247
|
|
6
補足
test
CHANGED
File without changes
|
test
CHANGED
@@ -232,9 +232,7 @@
|
|
232
232
|
|
233
233
|
|
234
234
|
|
235
|
-
phpmyAdminにてSHOW CREATE TABLE personaldata;実行結果↓
|
236
|
-
|
237
|
-
![イメージ説明](7
|
235
|
+
![イメージ説明](87b4d568dd92caef58deb799e105a5d2.png)
|
238
236
|
|
239
237
|
|
240
238
|
|
5
補足
test
CHANGED
File without changes
|
test
CHANGED
@@ -232,6 +232,12 @@
|
|
232
232
|
|
233
233
|
|
234
234
|
|
235
|
+
phpmyAdminにてSHOW CREATE TABLE personaldata;実行結果↓
|
236
|
+
|
237
|
+
![イメージ説明](701402c5994f60ce1b0209381b6d039b.png)
|
238
|
+
|
239
|
+
|
240
|
+
|
235
241
|
似たような質問もあったので参考にはしたんですが、それでも解決まで至れなかったのでアドバイスなどいただけると助かります!
|
236
242
|
|
237
243
|
|
4
補足
test
CHANGED
File without changes
|
test
CHANGED
@@ -228,6 +228,8 @@
|
|
228
228
|
|
229
229
|
```
|
230
230
|
|
231
|
+
![イメージ説明](aa226e8fb6c5b2777cf79650fb740811.png)
|
232
|
+
|
231
233
|
|
232
234
|
|
233
235
|
似たような質問もあったので参考にはしたんですが、それでも解決まで至れなかったのでアドバイスなどいただけると助かります!
|
3
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,248 +10,228 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
|
13
|
-
色々参考にしながら試みているのですが、チェックボックスでつまづいています。
|
13
|
+
色々参考にしながら試みているのですが、チェックボックスでつまづいています。
|
14
14
|
|
15
15
|
チェックボックスの箇所をコメントアウトしてみるとエラーがでなくてチェックボックス以外は登録できていました。
|
16
16
|
|
17
17
|
|
18
18
|
|
19
|
+
現在チェックボックス導入後、エラー表示はでないのですが、登録ができなくなっています。
|
20
|
+
|
21
|
+
|
22
|
+
|
19
|
-
以下
|
23
|
+
以下記述内容です
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
20
|
-
|
29
|
+
```html
|
21
|
-
|
22
|
-
|
30
|
+
|
23
|
-
|
31
|
+
<!DOCTYPE html>
|
32
|
+
|
33
|
+
<html lang="ja">
|
34
|
+
|
35
|
+
<head>
|
36
|
+
|
37
|
+
<meta charset="UTF-8">
|
38
|
+
|
39
|
+
<title>フォーム登録</title>
|
40
|
+
|
41
|
+
<link rel="stylesheet" type="text/css" href="css/test09_04.2.css">
|
42
|
+
|
43
|
+
</head>
|
44
|
+
|
45
|
+
<body>
|
46
|
+
|
47
|
+
<legend class="form"><h1>フォーム登録</h1>
|
48
|
+
|
49
|
+
<form name="form1" class="page1" id="page1" action="php/task_ex1.php" method="post">
|
50
|
+
|
51
|
+
<div>
|
52
|
+
|
53
|
+
<label for="textForm">名前:</label>
|
54
|
+
|
55
|
+
<input type="text" placeholder="名前入力してください" size="50" maxlength="50" name="name_form" id="textForm">
|
56
|
+
|
57
|
+
</div>
|
58
|
+
|
59
|
+
<div>
|
60
|
+
|
61
|
+
<label for="radioForm" class="gender">性別:</label>
|
62
|
+
|
63
|
+
<label for="gender1">男性</label><input type="radio" name="gender" value="男性" id="gender1">
|
64
|
+
|
65
|
+
<label for="gender2">女性</label><input type="radio" name="gender" value="女性" id="gender2">
|
66
|
+
|
67
|
+
<label for="gender3">その他</label><input type="radio" name="gender" value="その他" id="gender3" checked="checked">
|
68
|
+
|
69
|
+
</div>
|
70
|
+
|
71
|
+
<div class="age">
|
72
|
+
|
73
|
+
年齢:<select name="age" id="selbox">
|
74
|
+
|
75
|
+
<option value="~20代">~20代</option>
|
76
|
+
|
77
|
+
<option value="30代~40代">30代~40代</option>
|
78
|
+
|
79
|
+
<option value="50代~60代">50代~60代</option>
|
80
|
+
|
81
|
+
<option value="70代~">70代~</option>
|
82
|
+
|
83
|
+
</select>
|
84
|
+
|
85
|
+
</div>
|
86
|
+
|
87
|
+
<div class="questionnaire">
|
88
|
+
|
89
|
+
アンケート:好きな色(複数選択可)
|
90
|
+
|
91
|
+
<input type="checkbox" name="q1[]" value="赤" id="color1" ><label for="color1">赤</label>
|
92
|
+
|
93
|
+
<input type="checkbox" name="q1[]" value="青" id="color2" ><label for="color2">青</label>
|
94
|
+
|
95
|
+
<input type="checkbox" name="q1[]" value="黄" id="color3" ><label for="color3">黄</label>
|
96
|
+
|
97
|
+
<input type="checkbox" name="q1[]" value="緑" id="color4" ><label for="color4">緑</label>
|
98
|
+
|
99
|
+
<input type="checkbox" name="q1[]" value="紫" id="color5" ><label for="color5">紫</label>
|
100
|
+
|
101
|
+
</div>
|
102
|
+
|
103
|
+
<div class="free_space">
|
104
|
+
|
105
|
+
自由記入欄:<br>
|
106
|
+
|
107
|
+
<textarea id="freeSpace" name="free_space" cols="50" rows="6" placeholder="ご自由にご記入して下さい" ></textarea>
|
108
|
+
|
109
|
+
</div>
|
110
|
+
|
111
|
+
<div>
|
112
|
+
|
113
|
+
<input type="submit" id="button" value="取得する" >
|
114
|
+
|
115
|
+
<input type="reset" value="クリア">
|
116
|
+
|
117
|
+
</div>
|
118
|
+
|
119
|
+
</form>
|
120
|
+
|
121
|
+
</legend>
|
122
|
+
|
123
|
+
</body>
|
124
|
+
|
125
|
+
</html>
|
24
126
|
|
25
127
|
```
|
26
128
|
|
129
|
+
```php
|
130
|
+
|
131
|
+
<html>
|
132
|
+
|
27
|
-
|
133
|
+
<head>
|
28
|
-
|
29
|
-
|
30
|
-
|
134
|
+
|
31
|
-
|
135
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
136
|
+
|
32
|
-
|
137
|
+
<title>フォーム登録2</title>
|
138
|
+
|
139
|
+
</head>
|
140
|
+
|
141
|
+
<body>
|
142
|
+
|
143
|
+
<?php
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
$con = mysqli_connect('localhost','root','');
|
148
|
+
|
149
|
+
if (!$con) {
|
150
|
+
|
151
|
+
exit('データベースに接続できませんでした。');
|
152
|
+
|
153
|
+
}
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
$result = mysqli_select_db($con,'task_ex1_db');
|
158
|
+
|
159
|
+
if (!$result) {
|
160
|
+
|
161
|
+
exit('データベースを選択できませんでした。');
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
$result = mysqli_query($con,'SET NAMES utf8');
|
168
|
+
|
169
|
+
if (!$result) {
|
170
|
+
|
171
|
+
exit('文字コードを指定できませんでした。');
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
$name_form = addslashes($_REQUEST['name_form']);
|
178
|
+
|
179
|
+
$gender = addslashes($_REQUEST['gender']);
|
180
|
+
|
181
|
+
$age = addslashes($_REQUEST['age']);
|
182
|
+
|
183
|
+
//$q1 = addslashes($_REQUEST['q1']);
|
184
|
+
|
185
|
+
$q1;
|
186
|
+
|
187
|
+
if (!empty($_POST['q1'])){
|
188
|
+
|
189
|
+
$q1 = implode(',', $_POST['q1']);
|
190
|
+
|
191
|
+
}else{
|
192
|
+
|
193
|
+
$q1 = 'チェックなし';
|
194
|
+
|
195
|
+
}
|
196
|
+
|
197
|
+
$free_space = addslashes($_REQUEST['free_space']);
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
$result = mysqli_query($con,"INSERT INTO personaldata(name_form, gender, age, q1, free_space) VALUES('$name_form', '$gender', '$age', '$q1', '$free_space')");
|
202
|
+
|
203
|
+
if (!$result) {
|
204
|
+
|
33
|
-
データを登録できませんでした。
|
205
|
+
exit('データを登録できませんでした。');
|
206
|
+
|
207
|
+
}
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
$con = mysqli_close($con);
|
212
|
+
|
213
|
+
if (!$con) {
|
214
|
+
|
215
|
+
exit('データベースとの接続を閉じられませんでした。');
|
216
|
+
|
217
|
+
}
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
?>
|
222
|
+
|
223
|
+
<p>登録が完了しました。<br /><a href="../task_ex1.html">戻る</a></p>
|
224
|
+
|
225
|
+
</body>
|
226
|
+
|
227
|
+
</html>
|
34
228
|
|
35
229
|
```
|
36
230
|
|
37
231
|
|
38
232
|
|
39
|
-
・チェックボックスのチェック5つした時のエラー↓
|
40
|
-
|
41
|
-
```
|
42
|
-
|
43
|
-
Warning: addslashes() expects parameter 1 to be string, array given in C:\xampp\htdocs\フォーム登録\php\task_ex1.php on line 27
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
Warning: join(): Invalid arguments passed in C:\xampp\htdocs\フォーム登録\php\task_ex1.php on line 30
|
48
|
-
|
49
|
-
データを登録できませんでした。
|
50
|
-
|
51
|
-
```
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
```html
|
56
|
-
|
57
|
-
<!DOCTYPE html>
|
58
|
-
|
59
|
-
<html lang="ja">
|
60
|
-
|
61
|
-
<head>
|
62
|
-
|
63
|
-
<meta charset="UTF-8">
|
64
|
-
|
65
|
-
<title>フォーム登録</title>
|
66
|
-
|
67
|
-
<link rel="stylesheet" type="text/css" href="css/test09_04.2.css">
|
68
|
-
|
69
|
-
</head>
|
70
|
-
|
71
|
-
<body>
|
72
|
-
|
73
|
-
<legend class="form"><h1>フォーム登録</h1>
|
74
|
-
|
75
|
-
<form name="form1" class="page1" id="page1" action="php/task_ex1.php" method="post">
|
76
|
-
|
77
|
-
<div>
|
78
|
-
|
79
|
-
<label for="textForm">名前:</label>
|
80
|
-
|
81
|
-
<input type="text" placeholder="名前入力してください" size="50" maxlength="50" name="name_form" id="textForm">
|
82
|
-
|
83
|
-
</div>
|
84
|
-
|
85
|
-
<div>
|
86
|
-
|
87
|
-
<label for="radioForm" class="gender">性別:</label>
|
88
|
-
|
89
|
-
<label for="gender1">男性</label><input type="radio" name="gender" value="男性" id="gender1">
|
90
|
-
|
91
|
-
<label for="gender2">女性</label><input type="radio" name="gender" value="女性" id="gender2">
|
92
|
-
|
93
|
-
<label for="gender3">その他</label><input type="radio" name="gender" value="その他" id="gender3" checked="checked">
|
94
|
-
|
95
|
-
</div>
|
96
|
-
|
97
|
-
<div class="age">
|
98
|
-
|
99
|
-
年齢:<select name="age" id="selbox">
|
100
|
-
|
101
|
-
<option value="~20代">~20代</option>
|
102
|
-
|
103
|
-
<option value="30代~40代">30代~40代</option>
|
104
|
-
|
105
|
-
<option value="50代~60代">50代~60代</option>
|
106
|
-
|
107
|
-
<option value="70代~">70代~</option>
|
108
|
-
|
109
|
-
</select>
|
110
|
-
|
111
|
-
</div>
|
112
|
-
|
113
|
-
<div class="questionnaire">
|
114
|
-
|
115
|
-
アンケート:好きな色(複数選択可)
|
116
|
-
|
117
|
-
<input type="checkbox" name="q1[]" value="赤" id="color1" ><label for="color1">赤</label>
|
118
|
-
|
119
|
-
<input type="checkbox" name="q1[]" value="青" id="color2" ><label for="color2">青</label>
|
120
|
-
|
121
|
-
<input type="checkbox" name="q1[]" value="黄" id="color3" ><label for="color3">黄</label>
|
122
|
-
|
123
|
-
<input type="checkbox" name="q1[]" value="緑" id="color4" ><label for="color4">緑</label>
|
124
|
-
|
125
|
-
<input type="checkbox" name="q1[]" value="紫" id="color5" ><label for="color5">紫</label>
|
126
|
-
|
127
|
-
</div>
|
128
|
-
|
129
|
-
<div class="free_space">
|
130
|
-
|
131
|
-
自由記入欄:<br>
|
132
|
-
|
133
|
-
<textarea id="freeSpace" name="free_space" cols="50" rows="6" placeholder="ご自由にご記入して下さい" ></textarea>
|
134
|
-
|
135
|
-
</div>
|
136
|
-
|
137
|
-
<div>
|
138
|
-
|
139
|
-
<input type="submit" id="button" value="取得する" >
|
140
|
-
|
141
|
-
<input type="reset" value="クリア">
|
142
|
-
|
143
|
-
</div>
|
144
|
-
|
145
|
-
</form>
|
146
|
-
|
147
|
-
</legend>
|
148
|
-
|
149
|
-
</body>
|
150
|
-
|
151
|
-
</html>
|
152
|
-
|
153
|
-
```
|
154
|
-
|
155
|
-
```php
|
156
|
-
|
157
|
-
<html>
|
158
|
-
|
159
|
-
<head>
|
160
|
-
|
161
|
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
162
|
-
|
163
|
-
<title>フォーム登録2</title>
|
164
|
-
|
165
|
-
</head>
|
166
|
-
|
167
|
-
<body>
|
168
|
-
|
169
|
-
<?php
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
$con = mysqli_connect('localhost','root','');
|
174
|
-
|
175
|
-
if (!$con) {
|
176
|
-
|
177
|
-
exit('データベースに接続できませんでした。');
|
178
|
-
|
179
|
-
}
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
$result = mysqli_select_db($con,'task_ex1_db');
|
184
|
-
|
185
|
-
if (!$result) {
|
186
|
-
|
187
|
-
exit('データベースを選択できませんでした。');
|
188
|
-
|
189
|
-
}
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
$result = mysqli_query($con,'SET NAMES utf8');
|
194
|
-
|
195
|
-
if (!$result) {
|
196
|
-
|
197
|
-
exit('文字コードを指定できませんでした。');
|
198
|
-
|
199
|
-
}
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
$name_form = addslashes($_REQUEST['name_form']);
|
204
|
-
|
205
|
-
$gender = addslashes($_REQUEST['gender']);
|
206
|
-
|
207
|
-
$age = addslashes($_REQUEST['age']);
|
208
|
-
|
209
|
-
$q1 = addslashes($_REQUEST['q1']);
|
210
|
-
|
211
|
-
$free_space = addslashes($_REQUEST['free_space']);
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
$q1 = join(",", $q1);
|
216
|
-
|
217
|
-
$result = mysqli_query($con,"INSERT INTO personaldata(name_form, gender, age, q1, free_space) VALUES('$name_form', '$gender', '$age', '$q1', '$free_space')");
|
218
|
-
|
219
|
-
if (!$result) {
|
220
|
-
|
221
|
-
exit('データを登録できませんでした。');
|
222
|
-
|
223
|
-
}
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
$con = mysqli_close($con);
|
228
|
-
|
229
|
-
if (!$con) {
|
230
|
-
|
231
|
-
exit('データベースとの接続を閉じられませんでした。');
|
232
|
-
|
233
|
-
}
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
?>
|
238
|
-
|
239
|
-
<p>登録が完了しました。<br /><a href="../task_ex1.html">戻る</a></p>
|
240
|
-
|
241
|
-
</body>
|
242
|
-
|
243
|
-
</html>
|
244
|
-
|
245
|
-
```
|
246
|
-
|
247
|
-
|
248
|
-
|
249
233
|
似たような質問もあったので参考にはしたんですが、それでも解決まで至れなかったのでアドバイスなどいただけると助かります!
|
250
234
|
|
251
235
|
|
252
236
|
|
253
|
-
if文が必要なのかな??と今模索中です。
|
254
|
-
|
255
|
-
|
256
|
-
|
257
237
|
よろしくお願いいたしますm(_ _)m
|
2
補足
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,6 +18,10 @@
|
|
18
18
|
|
19
19
|
以下エラー表示と記述内容です
|
20
20
|
|
21
|
+
|
22
|
+
|
23
|
+
・チェックボックスのチェックなしの時のエラー↓
|
24
|
+
|
21
25
|
```
|
22
26
|
|
23
27
|
Notice: Undefined index: q1 in C:\xampp\htdocs\フォーム登録\php\task_ex1.php on line 27
|
@@ -30,6 +34,24 @@
|
|
30
34
|
|
31
35
|
```
|
32
36
|
|
37
|
+
|
38
|
+
|
39
|
+
・チェックボックスのチェック5つした時のエラー↓
|
40
|
+
|
41
|
+
```
|
42
|
+
|
43
|
+
Warning: addslashes() expects parameter 1 to be string, array given in C:\xampp\htdocs\フォーム登録\php\task_ex1.php on line 27
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
Warning: join(): Invalid arguments passed in C:\xampp\htdocs\フォーム登録\php\task_ex1.php on line 30
|
48
|
+
|
49
|
+
データを登録できませんでした。
|
50
|
+
|
51
|
+
```
|
52
|
+
|
53
|
+
|
54
|
+
|
33
55
|
```html
|
34
56
|
|
35
57
|
<!DOCTYPE html>
|
1
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -48,7 +48,7 @@
|
|
48
48
|
|
49
49
|
<body>
|
50
50
|
|
51
|
-
<legend class="form"><h1>
|
51
|
+
<legend class="form"><h1>フォーム登録</h1>
|
52
52
|
|
53
53
|
<form name="form1" class="page1" id="page1" action="php/task_ex1.php" method="post">
|
54
54
|
|