質問編集履歴
5
ソースコード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -358,6 +358,40 @@
|
|
358
358
|
|
359
359
|
|
360
360
|
|
361
|
+
・const.php
|
362
|
+
|
363
|
+
```php
|
364
|
+
|
365
|
+
<?php
|
366
|
+
|
367
|
+
$uploaddir = './drink_picture/';
|
368
|
+
|
369
|
+
$err_msg = [];
|
370
|
+
|
371
|
+
$complete_msg = [];
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
define('DB_HOST', '');
|
376
|
+
|
377
|
+
define('DB_USER', '');
|
378
|
+
|
379
|
+
define('DB_PASSWD', '');
|
380
|
+
|
381
|
+
define('DB_NAME', '');
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
define('HTML_CHARACTER_SET', 'UTF-8');
|
386
|
+
|
387
|
+
define('DB_CHARACTER_SET', 'UTF8');
|
388
|
+
|
389
|
+
date_default_timezone_set('Asia/Tokyo');
|
390
|
+
|
391
|
+
```
|
392
|
+
|
393
|
+
|
394
|
+
|
361
395
|
#試したこと
|
362
396
|
|
363
397
|
tool2.phpのforeach文に
|
4
ソースコード修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,496 +24,350 @@
|
|
24
24
|
|
25
25
|
function insert_drink($link) {
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
ca
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
27
|
+
|
28
|
+
|
29
|
+
$new_time = date('Y-m-d H:i:s');
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
$insert_data_info = [
|
34
|
+
|
35
|
+
'drink_name' => $new_name,
|
36
|
+
|
37
|
+
'price' => $new_price,
|
38
|
+
|
39
|
+
'created_at' => $new_time,
|
40
|
+
|
41
|
+
'updated_at' => $new_time,
|
42
|
+
|
43
|
+
'status' => $new_status
|
44
|
+
|
45
|
+
];
|
46
|
+
|
47
|
+
print_r($insert_data_info);
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
$sql = 'INSERT INTO drink_info_table(drink_name, price, created_at, updated_at, status) VALUES(\''.$new_name.'\',\''.$new_price.'\',\''.$new_time.'\',\''.$new_time.'\',\''.$new_status.'\')';
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
if ($result = mysqli_query($link, $sql) === TRUE) {
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
$drink_id = mysqli_insert_id($link);
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
$insert_data_stock = [
|
64
|
+
|
65
|
+
'drink_id' => $drink_id,
|
66
|
+
|
67
|
+
'stock' => $new_stock,
|
68
|
+
|
69
|
+
'created_at' => $new_time,
|
70
|
+
|
71
|
+
'updated_at' => $new_time
|
72
|
+
|
73
|
+
];
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
$sql = 'INSERT INTO stock_table(drink_id, stock, created_at, updated_at) VALUES(\''.$drink_id.'\',\''.$new_stock.'\',\''.$new_time.'\',\''.$new_time.'\')';
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
if ($result = mysqli_query($link, $sql) !== TRUE) {
|
82
|
+
|
83
|
+
$err_msg[] = 'stock_tableへのデータの登録に失敗しました';
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
} else {
|
88
|
+
|
89
|
+
$err_msg[] = 'drink_info_tableへのデータの登録に失敗しました';
|
50
90
|
|
51
91
|
}
|
52
92
|
|
53
|
-
}
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
if (isset($_POST['new_price']) === TRUE) {
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
switch (TRUE) {
|
62
|
-
|
63
|
-
case ($_POST['new_price'] === ''):
|
64
|
-
|
65
|
-
|
93
|
+
$complete_msg[] = '追加登録完了!';
|
66
|
-
|
67
|
-
break;
|
68
|
-
|
69
|
-
case ($_POST['new_price'] === NULL):
|
70
|
-
|
71
|
-
$err_msg[] = '値段を入力してください';
|
72
|
-
|
73
|
-
break;
|
74
|
-
|
75
|
-
case (preg_match('/^[0-9]+$/', $_POST['new_price']) !== 1):
|
76
|
-
|
77
|
-
$err_msg[] = '値段は0以上の半角整数を入力してください';
|
78
|
-
|
79
|
-
break;
|
80
|
-
|
81
|
-
default:
|
82
|
-
|
83
|
-
$new_price = $_POST['new_price'];
|
84
|
-
|
85
|
-
break;
|
86
94
|
|
87
95
|
}
|
88
96
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
c
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
97
|
+
```
|
98
|
+
|
99
|
+
・tool.php
|
100
|
+
|
101
|
+
```php
|
102
|
+
|
103
|
+
<?php
|
104
|
+
|
105
|
+
require_once('../../include/model/functions.php');
|
106
|
+
|
107
|
+
require_once('../../include/conf/const.php');
|
108
|
+
|
109
|
+
require_once('../../include/view/tool2.php');
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
$data = [
|
114
|
+
|
115
|
+
'drink_name' => '',
|
116
|
+
|
117
|
+
'price' => '',
|
118
|
+
|
119
|
+
'created_at' => '',
|
120
|
+
|
121
|
+
'updated_at' => '',
|
122
|
+
|
123
|
+
'status' => '',
|
124
|
+
|
125
|
+
];
|
126
|
+
|
127
|
+
$link = get_db_connect();
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
$data = insert_drink($link);
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
close_db_connect($link);
|
136
|
+
|
137
|
+
```
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
・tool2.php
|
142
|
+
|
143
|
+
```php
|
144
|
+
|
145
|
+
<!DOCTYPE html>
|
146
|
+
|
147
|
+
<html lang="ja">
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
<head>
|
152
|
+
|
153
|
+
<meta charset="UTF-8">
|
154
|
+
|
155
|
+
<title>自動販売機商品管理</title>
|
156
|
+
|
157
|
+
</head>
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
<body>
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
<?php if (count($complete_msg) !== 0) {
|
166
|
+
|
167
|
+
foreach ($complete_msg as $complete) { ?>
|
168
|
+
|
169
|
+
<p><?php print $complete; ?></p>
|
170
|
+
|
171
|
+
<?php }
|
172
|
+
|
173
|
+
} ?>
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
<?php if (count($err_msg) !== 0) {
|
178
|
+
|
179
|
+
foreach ($err_msg as $err) { ?>
|
180
|
+
|
181
|
+
<p><?php print $err; ?></p>
|
182
|
+
|
183
|
+
<?php }
|
184
|
+
|
185
|
+
} ?>
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
<h1>自動販売機管理ツール</h1>
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
<section>
|
194
|
+
|
195
|
+
<h2>新規商品追加</h2>
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
<form action="tool.php" method="post" enctype="multipart/form-data">
|
200
|
+
|
201
|
+
<label>名前: <input type="text" name="new_name" size="30" /></label><br>
|
202
|
+
|
203
|
+
<label>値段: <input type="text" name="new_price" size="30" /></label><br>
|
204
|
+
|
205
|
+
<label>個数: <input type="text" name="new_stock" size="30" /></label><br>
|
206
|
+
|
207
|
+
<input type="file" name="new_img" accept="image/jpeg, image/png, image/gif" /><br>
|
208
|
+
|
209
|
+
<select name="new_status"><br>
|
210
|
+
|
211
|
+
<option value="0">非公開</option>
|
212
|
+
|
213
|
+
<option value="1">公開</option>
|
214
|
+
|
215
|
+
<option value="2">入力チェック用</option>
|
216
|
+
|
217
|
+
</select><br>
|
218
|
+
|
219
|
+
<input type="hidden" name="sql_kind" value="insert">
|
220
|
+
|
221
|
+
<input type="submit" value="■□■□商品追加■□■□" />
|
222
|
+
|
223
|
+
</form>
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
</section>
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
<section>
|
232
|
+
|
233
|
+
<h2>商品情報変更</h2>
|
234
|
+
|
235
|
+
<table>
|
236
|
+
|
237
|
+
<caption>商品一覧</caption>
|
238
|
+
|
239
|
+
<tbody>
|
240
|
+
|
241
|
+
<tr>
|
242
|
+
|
243
|
+
<th>商品画像</th>
|
244
|
+
|
245
|
+
<th>商品名</th>
|
246
|
+
|
247
|
+
<th>価格</th>
|
248
|
+
|
249
|
+
<th>在庫数</th>
|
250
|
+
|
251
|
+
<th>ステータス</th>
|
252
|
+
|
253
|
+
</tr>
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
<?php if (empty($data) !== TRUE) {
|
258
|
+
|
259
|
+
foreach ($data as $list) {
|
260
|
+
|
261
|
+
print htmlspecialchars($list,ENT_QUOTES,'UTF-8');
|
262
|
+
|
263
|
+
if ((int) $list['status'] === 0) { ?>
|
264
|
+
|
265
|
+
<tr class="status_0">
|
266
|
+
|
267
|
+
<?php } else { ?>
|
268
|
+
|
269
|
+
<tr>
|
270
|
+
|
271
|
+
<?php } ?>
|
272
|
+
|
273
|
+
<td><img class="image" src="<?PHP print $list['path']; ?>"></td>
|
274
|
+
|
275
|
+
<? php print $list ?>
|
276
|
+
|
277
|
+
<td class="d_name"><?php print html_enc($list['drink_name']); ?></td>
|
278
|
+
|
279
|
+
<td class="d_price"><?php print $list['price']; ?></td>
|
280
|
+
|
281
|
+
<td>
|
282
|
+
|
283
|
+
<form method="post">
|
284
|
+
|
285
|
+
<input type="text" class="input_text_width text_align_right" name="update_stock" value="<?php print $list['stock']; ?>">個
|
286
|
+
|
287
|
+
<br>
|
288
|
+
|
289
|
+
<input type="submit" value="変更">
|
290
|
+
|
291
|
+
<input type="hidden" name="drink_id" value="<?php print $list['drink_id']; ?>">
|
292
|
+
|
293
|
+
<input type="hidden" name="sql_kind" value="update">
|
294
|
+
|
295
|
+
</form>
|
296
|
+
|
297
|
+
</td>
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
<?php if ((int) $list['status'] === 0) { ?>
|
302
|
+
|
303
|
+
<td class="d_status">
|
304
|
+
|
305
|
+
<form method="post">
|
306
|
+
|
307
|
+
<input type="submit" value="非公開 → 公開">
|
308
|
+
|
309
|
+
<input type="hidden" name="change_status" value="1">
|
310
|
+
|
311
|
+
<input type="hidden" name="drink_id" value="<?php print $list['drink_id']; ?>">
|
312
|
+
|
313
|
+
<input type="hidden" name="sql_kind" value="change">
|
314
|
+
|
315
|
+
</form>
|
316
|
+
|
317
|
+
</td>
|
318
|
+
|
319
|
+
</tr>
|
320
|
+
|
321
|
+
<?php } else { ?>
|
322
|
+
|
323
|
+
<td class="d_status">
|
324
|
+
|
325
|
+
<form method="post">
|
326
|
+
|
327
|
+
<input type="submit" value="公開 → 非公開">
|
328
|
+
|
329
|
+
<input type="hidden" name="change_status" value="0">
|
330
|
+
|
331
|
+
<input type="hidden" name="drink_id" value="<?php print $list['drink_id']; ?>">
|
332
|
+
|
333
|
+
<input type="hidden" name="sql_kind" value="change">
|
334
|
+
|
335
|
+
</form>
|
336
|
+
|
337
|
+
</td>
|
338
|
+
|
339
|
+
</tr>
|
340
|
+
|
341
|
+
<?php }
|
164
342
|
|
165
343
|
}
|
166
344
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
$err_msg[] = 'PNGかJPEG形式のファイルをアップロードしてください';
|
180
|
-
|
181
|
-
}
|
182
|
-
|
183
|
-
}
|
184
|
-
|
185
|
-
} else {
|
186
|
-
|
187
|
-
$err_msg[] = 'ファイルを選択してください';
|
188
|
-
|
189
|
-
}
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
if (isset($_POST['new_status']) === TRUE) {
|
196
|
-
|
197
|
-
if ((int) $_POST['new_status'] === 0 || (int) $_POST['new_status'] === 1) {
|
198
|
-
|
199
|
-
$new_status = (int) $_POST['new_status'];
|
200
|
-
|
201
|
-
} else {
|
202
|
-
|
203
|
-
$err_msg[] = 'ステータスは公開か非公開を選択してください';
|
204
|
-
|
205
|
-
}
|
206
|
-
|
207
|
-
} else {
|
208
|
-
|
209
|
-
$err_msg[] = 'ステータスを選択してください';
|
210
|
-
|
211
|
-
}
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
$new_time = date('Y-m-d H:i:s');
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
$insert_data_info = [
|
222
|
-
|
223
|
-
'drink_name' => $new_name,
|
224
|
-
|
225
|
-
'price' => $new_price,
|
226
|
-
|
227
|
-
'created_at' => $new_time,
|
228
|
-
|
229
|
-
'updated_at' => $new_time,
|
230
|
-
|
231
|
-
'status' => $new_status
|
232
|
-
|
233
|
-
];
|
234
|
-
|
235
|
-
print_r($insert_data_info);
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
$sql = 'INSERT INTO drink_info_table(drink_name, price, created_at, updated_at, status) VALUES(\''.$new_name.'\',\''.$new_price.'\',\''.$new_time.'\',\''.$new_time.'\',\''.$new_status.'\')';
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
if ($result = mysqli_query($link, $sql) === TRUE) {
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
$drink_id = mysqli_insert_id($link);
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
$insert_data_stock = [
|
252
|
-
|
253
|
-
'drink_id' => $drink_id,
|
254
|
-
|
255
|
-
'stock' => $new_stock,
|
256
|
-
|
257
|
-
'created_at' => $new_time,
|
258
|
-
|
259
|
-
'updated_at' => $new_time
|
260
|
-
|
261
|
-
];
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
$sql = 'INSERT INTO stock_table(drink_id, stock, created_at, updated_at) VALUES(\''.$drink_id.'\',\''.$new_stock.'\',\''.$new_time.'\',\''.$new_time.'\')';
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
if ($result = mysqli_query($link, $sql) !== TRUE) {
|
270
|
-
|
271
|
-
$err_msg[] = 'stock_tableへのデータの登録に失敗しました';
|
272
|
-
|
273
|
-
}
|
274
|
-
|
275
|
-
} else {
|
276
|
-
|
277
|
-
$err_msg[] = 'drink_info_tableへのデータの登録に失敗しました';
|
278
|
-
|
279
|
-
}
|
280
|
-
|
281
|
-
$complete_msg[] = '追加登録完了!';
|
282
|
-
|
283
|
-
}
|
345
|
+
} ?>
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
</tbody>
|
350
|
+
|
351
|
+
</table>
|
352
|
+
|
353
|
+
</section>
|
354
|
+
|
355
|
+
</body>
|
284
356
|
|
285
357
|
```
|
286
358
|
|
359
|
+
|
360
|
+
|
361
|
+
#試したこと
|
362
|
+
|
287
|
-
|
363
|
+
tool2.phpのforeach文に
|
288
364
|
|
289
365
|
```php
|
290
366
|
|
291
|
-
<!DOCTYPE html>
|
292
|
-
|
293
|
-
<html lang="ja">
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
<head>
|
298
|
-
|
299
|
-
<meta charset="UTF-8">
|
300
|
-
|
301
|
-
<title>自動販売機商品管理</title>
|
302
|
-
|
303
|
-
</head>
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
<body>
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
<?php if (count($complete_msg) !== 0) {
|
312
|
-
|
313
|
-
foreach ($complete_msg as $complete) { ?>
|
314
|
-
|
315
|
-
<p><?php print $complete; ?></p>
|
316
|
-
|
317
|
-
<?php }
|
318
|
-
|
319
|
-
} ?>
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
<?php if (count($err_msg) !== 0) {
|
324
|
-
|
325
|
-
foreach ($err_msg as $err) { ?>
|
326
|
-
|
327
|
-
<p><?php print $err; ?></p>
|
328
|
-
|
329
|
-
<?php }
|
330
|
-
|
331
|
-
} ?>
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
<h1>自動販売機管理ツール</h1>
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
<section>
|
340
|
-
|
341
|
-
<h2>新規商品追加</h2>
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
<form action="tool.php" method="post" enctype="multipart/form-data">
|
346
|
-
|
347
|
-
<label>名前: <input type="text" name="new_name" size="30" /></label><br>
|
348
|
-
|
349
|
-
<label>値段: <input type="text" name="new_price" size="30" /></label><br>
|
350
|
-
|
351
|
-
<label>個数: <input type="text" name="new_stock" size="30" /></label><br>
|
352
|
-
|
353
|
-
<input type="file" name="new_img" accept="image/jpeg, image/png, image/gif" /><br>
|
354
|
-
|
355
|
-
<select name="new_status"><br>
|
356
|
-
|
357
|
-
<option value="0">非公開</option>
|
358
|
-
|
359
|
-
<option value="1">公開</option>
|
360
|
-
|
361
|
-
<option value="2">入力チェック用</option>
|
362
|
-
|
363
|
-
</select><br>
|
364
|
-
|
365
|
-
<input type="hidden" name="sql_kind" value="insert">
|
366
|
-
|
367
|
-
<input type="submit" value="■□■□商品追加■□■□" />
|
368
|
-
|
369
|
-
</form>
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
</section>
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
<section>
|
378
|
-
|
379
|
-
<h2>商品情報変更</h2>
|
380
|
-
|
381
|
-
<table>
|
382
|
-
|
383
|
-
<caption>商品一覧</caption>
|
384
|
-
|
385
|
-
<tbody>
|
386
|
-
|
387
|
-
<tr>
|
388
|
-
|
389
|
-
<th>商品画像</th>
|
390
|
-
|
391
|
-
<th>商品名</th>
|
392
|
-
|
393
|
-
<th>価格</th>
|
394
|
-
|
395
|
-
<th>在庫数</th>
|
396
|
-
|
397
|
-
<th>ステータス</th>
|
398
|
-
|
399
|
-
</tr>
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
<?php if (empty($data) !== TRUE) {
|
404
|
-
|
405
|
-
foreach ($data as $list) {
|
406
|
-
|
407
|
-
|
367
|
+
print htmlspecialchars($list,ENT_QUOTES,'UTF-8');
|
408
|
-
|
409
|
-
if ((int) $list['status'] === 0) { ?>
|
410
|
-
|
411
|
-
<tr class="status_0">
|
412
|
-
|
413
|
-
<?php } else { ?>
|
414
|
-
|
415
|
-
<tr>
|
416
|
-
|
417
|
-
<?php } ?>
|
418
|
-
|
419
|
-
<td><img class="image" src="<?PHP print $list['path']; ?>"></td>
|
420
|
-
|
421
|
-
<? php print $list ?>
|
422
|
-
|
423
|
-
<td class="d_name"><?php print html_enc($list['drink_name']); ?></td>
|
424
|
-
|
425
|
-
<td class="d_price"><?php print $list['price']; ?></td>
|
426
|
-
|
427
|
-
<td>
|
428
|
-
|
429
|
-
<form method="post">
|
430
|
-
|
431
|
-
<input type="text" class="input_text_width text_align_right" name="update_stock" value="<?php print $list['stock']; ?>">個
|
432
|
-
|
433
|
-
<br>
|
434
|
-
|
435
|
-
<input type="submit" value="変更">
|
436
|
-
|
437
|
-
<input type="hidden" name="drink_id" value="<?php print $list['drink_id']; ?>">
|
438
|
-
|
439
|
-
<input type="hidden" name="sql_kind" value="update">
|
440
|
-
|
441
|
-
</form>
|
442
|
-
|
443
|
-
</td>
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
<?php if ((int) $list['status'] === 0) { ?>
|
448
|
-
|
449
|
-
<td class="d_status">
|
450
|
-
|
451
|
-
<form method="post">
|
452
|
-
|
453
|
-
<input type="submit" value="非公開 → 公開">
|
454
|
-
|
455
|
-
<input type="hidden" name="change_status" value="1">
|
456
|
-
|
457
|
-
<input type="hidden" name="drink_id" value="<?php print $list['drink_id']; ?>">
|
458
|
-
|
459
|
-
<input type="hidden" name="sql_kind" value="change">
|
460
|
-
|
461
|
-
</form>
|
462
|
-
|
463
|
-
</td>
|
464
|
-
|
465
|
-
</tr>
|
466
|
-
|
467
|
-
<?php } else { ?>
|
468
|
-
|
469
|
-
<td class="d_status">
|
470
|
-
|
471
|
-
<form method="post">
|
472
|
-
|
473
|
-
<input type="submit" value="公開 → 非公開">
|
474
|
-
|
475
|
-
<input type="hidden" name="change_status" value="0">
|
476
|
-
|
477
|
-
<input type="hidden" name="drink_id" value="<?php print $list['drink_id']; ?>">
|
478
|
-
|
479
|
-
<input type="hidden" name="sql_kind" value="change">
|
480
|
-
|
481
|
-
</form>
|
482
|
-
|
483
|
-
</td>
|
484
|
-
|
485
|
-
</tr>
|
486
|
-
|
487
|
-
<?php }
|
488
|
-
|
489
|
-
}
|
490
|
-
|
491
|
-
} ?>
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
</tbody>
|
496
|
-
|
497
|
-
</table>
|
498
|
-
|
499
|
-
</section>
|
500
|
-
|
501
|
-
</body>
|
502
368
|
|
503
369
|
```
|
504
370
|
|
505
|
-
|
506
|
-
|
507
|
-
#試したこと
|
508
|
-
|
509
|
-
tool2.phpのforeach文に
|
510
|
-
|
511
|
-
```php
|
512
|
-
|
513
|
-
print htmlspecialchars($list,ENT_QUOTES,'UTF-8');
|
514
|
-
|
515
|
-
```
|
516
|
-
|
517
371
|
を追加しましたが、全く変わらないです。
|
518
372
|
|
519
373
|
#補足情報(FW/ツールのバージョンなど)
|
3
ソースコード訂正
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
ソースコード
|
20
20
|
|
21
|
-
functions.php
|
21
|
+
・functions.php
|
22
22
|
|
23
23
|
```php
|
24
24
|
|
@@ -284,7 +284,7 @@
|
|
284
284
|
|
285
285
|
```
|
286
286
|
|
287
|
-
tool2.php
|
287
|
+
・tool2.php
|
288
288
|
|
289
289
|
```php
|
290
290
|
|
2
そ
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,57 +20,267 @@
|
|
20
20
|
|
21
21
|
functions.php
|
22
22
|
|
23
|
-
![イメージ説明](02f00ca4e13144a0eb978e20b9172c93.png)
|
24
|
-
|
25
|
-
![イメージ説明](c795f375684f3c4d7b4b30eac0aa17f4.png)
|
26
|
-
|
27
|
-
![イメージ説明](37fe5c5a5fc54a75c4cc68c1c42c1b6c.png)
|
28
|
-
|
29
|
-
![イメージ説明](3d5c0a7684773aabefe50eca271feb9f.png)
|
30
|
-
|
31
|
-
![イメージ説明](df43f14e716f0fcd489e9600425302ab.png)
|
32
|
-
|
33
|
-
![イメージ説明](150577286cb760b862cef516229d7807.png)
|
34
|
-
|
35
|
-
![イメージ説明](e4d41badf0d884b5761f0af763faf1e8.png)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
tool.php
|
40
|
-
|
41
23
|
```php
|
42
24
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
$
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
25
|
+
function insert_drink($link) {
|
26
|
+
|
27
|
+
if ($_SERVER['REQUEST_METHOD'] === 'POST' && $_POST['sql_kind'] === 'insert') {
|
28
|
+
|
29
|
+
if (isset($_POST['new_name']) === TRUE) {
|
30
|
+
|
31
|
+
switch (TRUE) {
|
32
|
+
|
33
|
+
case ($_POST['new_name'] === ''):
|
34
|
+
|
35
|
+
$err_msg[] = '商品名を入力してください';
|
36
|
+
|
37
|
+
break;
|
38
|
+
|
39
|
+
case ($_POST['new_name'] === NULL);
|
40
|
+
|
41
|
+
$err_msg[] = '商品名を入力してください';
|
42
|
+
|
43
|
+
break;
|
44
|
+
|
45
|
+
default:
|
46
|
+
|
47
|
+
$new_name = $_POST['new_name'];
|
48
|
+
|
49
|
+
break;
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
}
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
if (isset($_POST['new_price']) === TRUE) {
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
switch (TRUE) {
|
62
|
+
|
63
|
+
case ($_POST['new_price'] === ''):
|
64
|
+
|
65
|
+
$err_msg[] = '値段を入力してください';
|
66
|
+
|
67
|
+
break;
|
68
|
+
|
69
|
+
case ($_POST['new_price'] === NULL):
|
70
|
+
|
71
|
+
$err_msg[] = '値段を入力してください';
|
72
|
+
|
73
|
+
break;
|
74
|
+
|
75
|
+
case (preg_match('/^[0-9]+$/', $_POST['new_price']) !== 1):
|
76
|
+
|
77
|
+
$err_msg[] = '値段は0以上の半角整数を入力してください';
|
78
|
+
|
79
|
+
break;
|
80
|
+
|
81
|
+
default:
|
82
|
+
|
83
|
+
$new_price = $_POST['new_price'];
|
84
|
+
|
85
|
+
break;
|
86
|
+
|
87
|
+
}
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
if (isset($_POST['new_stock']) === TRUE) {
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
switch (TRUE) {
|
98
|
+
|
99
|
+
case ($_POST['new_stock'] === ''):
|
100
|
+
|
101
|
+
$err_msg[] = '個数を入力してください';
|
102
|
+
|
103
|
+
break;
|
104
|
+
|
105
|
+
case ($_POST['new_stock'] === NULL):
|
106
|
+
|
107
|
+
$err_msg[] = '個数を入力してください';
|
108
|
+
|
109
|
+
break;
|
110
|
+
|
111
|
+
case (preg_match('/^[0-9]+$/', $_POST['new_stock']) !== 1):
|
112
|
+
|
113
|
+
$err_msg[] = '在庫は0以上の半角整数を入力してください';
|
114
|
+
|
115
|
+
break;
|
116
|
+
|
117
|
+
default:
|
118
|
+
|
119
|
+
$new_stock = $_POST['new_stock'];
|
120
|
+
|
121
|
+
break;
|
122
|
+
|
123
|
+
}
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
if ($_FILES['new_img']['error'] === UPLOAD_ERR_OK) {
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
$chk_picture = getimagesize($_FILES['new_img']['tmp_name']);
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
if ($chk_picture['mime'] === 'image/png' || $chk_picture['mime'] === 'image/jpeg') {
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
if ($chk_picture[0] <= 500 && ($chk_picture[1] <= 500)) {
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
$mime = $chk_picture['mime'];
|
150
|
+
|
151
|
+
switch ($mime) {
|
152
|
+
|
153
|
+
case 'image/png':
|
154
|
+
|
155
|
+
$type = '.png';
|
156
|
+
|
157
|
+
break;
|
158
|
+
|
159
|
+
case 'image/jpeg':
|
160
|
+
|
161
|
+
$type = '.jpg';
|
162
|
+
|
163
|
+
break;
|
164
|
+
|
165
|
+
}
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
} else {
|
172
|
+
|
173
|
+
$err_msg[] = 'ファイルは縦と横500px以内にしてください';
|
174
|
+
|
175
|
+
}
|
176
|
+
|
177
|
+
} else {
|
178
|
+
|
179
|
+
$err_msg[] = 'PNGかJPEG形式のファイルをアップロードしてください';
|
180
|
+
|
181
|
+
}
|
182
|
+
|
183
|
+
}
|
184
|
+
|
185
|
+
} else {
|
186
|
+
|
187
|
+
$err_msg[] = 'ファイルを選択してください';
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
if (isset($_POST['new_status']) === TRUE) {
|
196
|
+
|
197
|
+
if ((int) $_POST['new_status'] === 0 || (int) $_POST['new_status'] === 1) {
|
198
|
+
|
199
|
+
$new_status = (int) $_POST['new_status'];
|
200
|
+
|
201
|
+
} else {
|
202
|
+
|
203
|
+
$err_msg[] = 'ステータスは公開か非公開を選択してください';
|
204
|
+
|
205
|
+
}
|
206
|
+
|
207
|
+
} else {
|
208
|
+
|
209
|
+
$err_msg[] = 'ステータスを選択してください';
|
210
|
+
|
211
|
+
}
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
$new_time = date('Y-m-d H:i:s');
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
$insert_data_info = [
|
222
|
+
|
223
|
+
'drink_name' => $new_name,
|
224
|
+
|
225
|
+
'price' => $new_price,
|
226
|
+
|
227
|
+
'created_at' => $new_time,
|
228
|
+
|
229
|
+
'updated_at' => $new_time,
|
230
|
+
|
231
|
+
'status' => $new_status
|
62
232
|
|
63
233
|
];
|
64
234
|
|
65
|
-
$
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
$
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
235
|
+
print_r($insert_data_info);
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
$sql = 'INSERT INTO drink_info_table(drink_name, price, created_at, updated_at, status) VALUES(\''.$new_name.'\',\''.$new_price.'\',\''.$new_time.'\',\''.$new_time.'\',\''.$new_status.'\')';
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
if ($result = mysqli_query($link, $sql) === TRUE) {
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
$drink_id = mysqli_insert_id($link);
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
$insert_data_stock = [
|
252
|
+
|
253
|
+
'drink_id' => $drink_id,
|
254
|
+
|
255
|
+
'stock' => $new_stock,
|
256
|
+
|
257
|
+
'created_at' => $new_time,
|
258
|
+
|
259
|
+
'updated_at' => $new_time
|
260
|
+
|
261
|
+
];
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
$sql = 'INSERT INTO stock_table(drink_id, stock, created_at, updated_at) VALUES(\''.$drink_id.'\',\''.$new_stock.'\',\''.$new_time.'\',\''.$new_time.'\')';
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
if ($result = mysqli_query($link, $sql) !== TRUE) {
|
270
|
+
|
271
|
+
$err_msg[] = 'stock_tableへのデータの登録に失敗しました';
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
} else {
|
276
|
+
|
277
|
+
$err_msg[] = 'drink_info_tableへのデータの登録に失敗しました';
|
278
|
+
|
279
|
+
}
|
280
|
+
|
281
|
+
$complete_msg[] = '追加登録完了!';
|
282
|
+
|
283
|
+
}
|
74
284
|
|
75
285
|
```
|
76
286
|
|
@@ -294,54 +504,16 @@
|
|
294
504
|
|
295
505
|
|
296
506
|
|
507
|
+
#試したこと
|
508
|
+
|
297
|
-
|
509
|
+
tool2.phpのforeach文に
|
298
510
|
|
299
511
|
```php
|
300
512
|
|
301
|
-
<?php
|
302
|
-
|
303
|
-
$uploaddir = './drink_picture/';
|
304
|
-
|
305
|
-
$err_msg = [];
|
306
|
-
|
307
|
-
$complete_msg = [];
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
define('DB_HOST', '');
|
312
|
-
|
313
|
-
define('DB_USER', '');
|
314
|
-
|
315
|
-
define('DB_PASSWD', '');
|
316
|
-
|
317
|
-
define('DB_NAME', '');
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
513
|
+
print htmlspecialchars($list,ENT_QUOTES,'UTF-8');
|
322
|
-
|
323
|
-
define('DB_CHARACTER_SET', 'UTF8');
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
date_default_timezone_set('Asia/Tokyo');
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
</html>
|
332
514
|
|
333
515
|
```
|
334
516
|
|
335
|
-
#試したこと
|
336
|
-
|
337
|
-
tool2.phpのforeach文に
|
338
|
-
|
339
|
-
```php
|
340
|
-
|
341
|
-
print htmlspecialchars($list,ENT_QUOTES,'UTF-8');
|
342
|
-
|
343
|
-
```
|
344
|
-
|
345
517
|
を追加しましたが、全く変わらないです。
|
346
518
|
|
347
519
|
#補足情報(FW/ツールのバージョンなど)
|
1
一部訂正
test
CHANGED
File without changes
|
test
CHANGED
@@ -312,9 +312,9 @@
|
|
312
312
|
|
313
313
|
define('DB_USER', '');
|
314
314
|
|
315
|
-
define('DB_PASSWD', '
|
315
|
+
define('DB_PASSWD', '');
|
316
|
-
|
316
|
+
|
317
|
-
define('DB_NAME', '
|
317
|
+
define('DB_NAME', '');
|
318
318
|
|
319
319
|
|
320
320
|
|