質問編集履歴
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -243,3 +243,67 @@
|
|
243
243
|
</html>
|
244
244
|
|
245
245
|
```
|
246
|
+
|
247
|
+
登録処理部分です
|
248
|
+
|
249
|
+
```ここに言語を入力
|
250
|
+
|
251
|
+
<?php
|
252
|
+
|
253
|
+
// エラー出力しない場合
|
254
|
+
|
255
|
+
ini_set('display_errors', 0);
|
256
|
+
|
257
|
+
?>
|
258
|
+
|
259
|
+
<?php
|
260
|
+
|
261
|
+
require_once('class_db.php');
|
262
|
+
|
263
|
+
////POSTで変数'id'が渡されていた場合の処理
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
//DBへPOSTで渡されたデータの挿入
|
268
|
+
|
269
|
+
if(isset($_POST['g_id'])){
|
270
|
+
|
271
|
+
//POSTのデータを変数に代入+型チェック
|
272
|
+
|
273
|
+
$g_id = (int)filter_input(INPUT_POST, 'g_id');
|
274
|
+
|
275
|
+
$g_name= (string)filter_input(INPUT_POST, 'g_name');
|
276
|
+
|
277
|
+
$g_title= (string)filter_input(INPUT_POST, 'g_title');
|
278
|
+
|
279
|
+
$g_text= (string)filter_input(INPUT_POST, 'g_text');
|
280
|
+
|
281
|
+
}
|
282
|
+
|
283
|
+
////DB接続
|
284
|
+
|
285
|
+
$pdo= new connect();session_start();
|
286
|
+
|
287
|
+
if (isset($_POST['insert'])) {
|
288
|
+
|
289
|
+
$_SESSION['g_id'] = $_POST["g_id"];
|
290
|
+
|
291
|
+
}
|
292
|
+
|
293
|
+
////DB接続
|
294
|
+
|
295
|
+
$pdo= new connect();
|
296
|
+
|
297
|
+
// INSERT文を実行
|
298
|
+
|
299
|
+
$sql= "INSERT INTO genre VALUES (?,?,?,?)";
|
300
|
+
|
301
|
+
$stmt= $pdo->vind_query($sql, $g_id, $g_name, $g_title, $g_text);
|
302
|
+
|
303
|
+
echo "$g_id<br>$g_name<br>$g_title<br>$g_text<br>登録しました。<br>";
|
304
|
+
|
305
|
+
echo '<button type="button" onclick="history.back()">戻る</button>';
|
306
|
+
|
307
|
+
?>
|
308
|
+
|
309
|
+
```
|